Programming Articles

Page 168 of 2547

How to add multiple text labels from DataFrame columns in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 3K+ Views

Plotly is a powerful Python library for creating interactive visualizations. You can add multiple text labels from DataFrame columns to enhance your charts with additional information that appears on hover or as annotations. In this tutorial, we'll learn how to create a scatter plot with text labels from different DataFrame columns using Plotly's graph_objects module. Required Libraries We'll use the following Python libraries ? plotly.graph_objects − For creating interactive plots pandas − For DataFrame operations plotly.offline − For generating HTML output Creating the DataFrame First, let's create a sample DataFrame with student ...

Read More

Python Program to calculate the area of the rhombus

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 26-Mar-2026 3K+ Views

A rhombus is a four-sided polygon with all equal edges and perpendicular diagonals. It is a special type of parallelogram where opposite sides are equal and parallel. p q equal sides The area of a rhombus is calculated using its diagonals, as they form four triangles within the figure. The mathematical formula is − Area = (p × q) / 2 Where p and q are the lengths of the diagonals. Input Output Scenarios Let us look ...

Read More

Python Program to calculate the volume and area of Sphere

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 26-Mar-2026 7K+ Views

A sphere is a three-dimensional geometric figure where every point on its surface is equidistant from the center. We can calculate both the surface area and volume of spheres using mathematical formulas. r Solid Sphere R r Hollow Sphere Formulas The mathematical formulas for calculating sphere properties are − Surface Area ...

Read More

Python Program to calculate the volume and area of Cone

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 26-Mar-2026 5K+ Views

A cone is a three-dimensional figure formed by connecting infinite line segments from a common point (apex) to all points on a circular base. The cone has three key measurements: radius of the circular base, height, and lateral height (slant height). The height is measured from the apex to the center of the circular base, while the lateral height (or slant height) is the distance from the apex to any point on the circumference of the base. ...

Read More

How to add multiple graphs to a Plotly Dash app on a single browser page in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 5K+ Views

Plotly Dash is a Python framework for building interactive web applications. You can add multiple graphs to a single Dash app by organizing them within HTML Div components and using dcc.Graph elements. Setting Up Multiple Graphs To create multiple graphs on one page, you need to structure your layout with separate html.Div containers for each graph ? import dash from dash import dcc, html import pandas as pd import plotly.express as px # Initialize the Dash app app = dash.Dash(__name__) # Create sample data df_seasons = pd.DataFrame({ "Season": ["Summer", "Winter", ...

Read More

Python Plotly – How to hide legend entries in a Plotly figure?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 2K+ Views

Plotly is a powerful open-source plotting library in Python that creates interactive web-based visualizations. Sometimes you may want to hide specific legend entries to reduce clutter or highlight only certain data series in your plots. In this tutorial, we will demonstrate different methods to hide legend entries in Plotly figures using the showlegend parameter. Method 1: Using showlegend Parameter The most direct way to hide legend entries is by setting showlegend=False when creating traces ? import plotly.graph_objects as go import plotly.offline as py # Create sample data x = [1, 2, 3, 4, 5] ...

Read More

How to shade a chart above a specific Y value in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 644 Views

Plotly is a powerful plotting library in Python that enables you to create interactive visualizations. Sometimes you need to highlight specific regions of your chart by shading areas above or below certain Y values to emphasize important thresholds or ranges. In this tutorial, we will show how to shade a chart above a specific Y value using Plotly's add_hrect() method. Understanding the Methods To shade chart areas, we use these key Plotly methods: add_hrect() − Adds a horizontal rectangle to shade regions based on Y-axis values add_vline() − Adds vertical reference lines plotly.express − Creates ...

Read More

Python Plotly – How to change variable/label names for the legend in a line chart?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 8K+ Views

Plotly is an open-source, interactive, and browser-based charting library for Python. Python users can use Plotly to generate different types of charts including scientific charts, 3D graphs, statistical charts, financial charts, etc. In this tutorial, we will show how you can use Plotly to change the variable and label names for the legend in a line chart. The name parameter in scatter traces controls legend labels, while legend_title customizes the legend title. Basic Setup First, import the required module and create a figure object ? import plotly.graph_objs as go # Create a figure object ...

Read More

How to plot multiple lines on the same Y-axis in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 35K+ Views

Plotly is an open-source plotting library in Python that creates interactive web-based visualizations. In this tutorial, we will show how to plot multiple lines on the same Y-axis using plotly.express and pandas. When working with time-series data or comparing multiple metrics, plotting multiple lines on the same chart helps visualize trends and relationships between different datasets. Method 1: Using add_scatter() First, create a line plot and then add another line using add_scatter() method ? import plotly.express as px import pandas as pd # Create dataset data = { 'year': [2015, ...

Read More

Python Plotly – How to simultaneously apply color/shape/size in a Scatter Plot?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 1K+ Views

Plotly is an open-source Python library for creating interactive web-based visualizations. In this tutorial, we'll explore how to simultaneously apply color, shape, and size properties to scatter plots for enhanced data visualization. Understanding Scatter Plot Properties Scatter plots can be customized with multiple visual properties: Color − Maps data values to different colors using color scales Size − Varies marker sizes based on data values Shape − Uses different marker symbols to represent categories Basic Scatter Plot with Color and Size Let's create a scatter plot where color and size represent different data ...

Read More
Showing 1671–1680 of 25,469 articles
« Prev 1 166 167 168 169 170 2547 Next »
Advertisements