Rishikesh Kumar Rishi has Published 1162 Articles

Darken or lighten a color in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:36:30

5K+ Views

To darken and lighten the color, we can chage the alpha value in the argument of plot() method.Greater the aplha value, darker will be the color.StepsCreate data points for xs and ys using numpy.Plot two lines with different value of alpha, to replicate darker and lighter color of the linesPlace ... Read More

How do I change the range of the X-axis with datetimes in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:35:17

8K+ Views

To change the range of the X-axis with datetimes in matplotlib, we can take the following steps −Create a list of x and y, where x stores the datetime and y stores the number.Using subplots method, create a figure and add a set of subplots.Plot x and y data points using plots() method, wehere markerface ... Read More

How to change the plot line color from blue to black in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:34:57

2K+ Views

To change the plot line color from blue to black, we can use setcolor() method−StepsCreate x and y data points using numpy.Plot line x and y using plot() method; store the returned value in line.Set the color as black using set_color() method.To display the figure, use show() method.Exampleimport numpy as ... Read More

Determine Matplotlib axis size in pixels

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:34:35

3K+ Views

To determine the axis size in pixels, we can take the following steps −Create a figure and a set of subplots, using subplots() method, fig and ax.To get the DPI, use fig.dpi. Print the details.Find bounding box in the display box.Find the width and height, using bbox.width and bbox.height.Print the width and ... Read More

How to make a multicolored point in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:34:14

218 Views

To make a multicolored point in matplotlib, we can take the following steps−Initialize two varuables, x and y.Use scatter method with x and y data points with green color having marker size 2000.Use scatter method with x and y data points with red color having marker size 1000.Use scatter method ... Read More

How to add percentages on top of bars in Seaborn using Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:33:49

6K+ Views

To add percentages on top of bars in Seaborn, we can take the following steps −Create the lists, x, y and percentages to plot using Seaborn.Using barplot, show point estimates and confidence intervals with bars. Store the returned axis.Find patches from the returned axis (In step 2).Iterate the patches (returned in ... Read More

How to decouple hatch and edge color in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:33:30

792 Views

To decouple hatch and edge color in matplotlib, we can use hatch color “o” and edge color “red”.−StepsCreate a new figure or activate existing figure.Add a subplot arrangement to the current axes.Create two lists of data points.Use bar() method with hatch and edgecolor.To display the figure, use show() method.Exampleimport matplotlib.pyplot ... Read More

How do I extend the margin at the bottom of a figure in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:28:47

562 Views

To fix the extension of margin at the bottom of a figure, we can take the following steps −Using Pandas dataframe, create a df with the keys, time and speed.Plot df.time and df.speed using plot() method.Tick_params() is a convenience method for changing the appearance of ticks and tick labels. rotation=90 extends the tick ... Read More

How can I set the background color on specific areas of a Pyplot figure using Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:28:27

2K+ Views

To set the background color on specific areas of a pyplot, we can take the following steps −Using subplots() method, create a figure and a set of subplots, where nrows=1.Using rectangle, we can create a rectangle, defined via an anchor point and its width and height. Where, edgecolor=orange, linewidth=7, and ... Read More

How to set my xlabel at the end of X-axis in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:28:01

10K+ Views

To set the xlabel at the end of X-axis in matplotlib, we can take the following steps −Create data points for x using numpy.Using subplot() method, add a subplot to the current figure.Plot x and log(x) using plot() method.Set the label on X-axis using set_label() method, with fontsize=16, loc=left, and color=red.To set the xlabel at the end ... Read More

Advertisements