Questions tagged [matplotlib]

Matplotlib is a plotting library for Python which may be used interactively or embedded in stand-alone GUIs. Its compact "pyplot" interface is similar to the plotting functions of MATLAB®.

Matplotlib is a comprehensive plotting and visualization library for the Python programming language and its NumPy numerical mathematics extension. It provides an object-oriented API for embedding plots into applications using general-purpose GUI toolkits like tkinter, wxPython, Qt, or GTK, Jupyter and IPython notebooks.

There is also a procedural "pyplot" interface based on a state machine (like OpenGL), designed to closely resemble that of MATLAB.

Matplotlib can output PNG, PDF, PS, EPS, TIFF, JPEG, PGF, and SVG files, or plot in windows using a variety of toolkits (including plot animation).

Latest release information on Matplotlib's site.

Resources to get started:

71303 questions
24
votes
2 answers

How to highlight one point in a matplotlib plot

Suppose, I have the following two lists that correspond to x- and y-coordinates. x = [1,2,3,4,5,6] y = [3,4,5,6,7,8] I want the first pair (1,3) to be in a different color or shape. How can this be done using python?
Abhinav Goel
  • 401
  • 1
  • 6
  • 13
24
votes
5 answers

How to remove the space between subplots in matplotlib.pyplot?

I am working on a project in which I need to put together a plot grid of 10 rows and 3 columns. Although I have been able to make the plots and arrange the subplots, I was not able to produce a nice plot without white space such as this one below…
George Liu
  • 3,601
  • 10
  • 43
  • 69
24
votes
3 answers

Scatter plot with a huge amount of data

I would like to use Matplotlib to generate a scatter plot with a huge amount of data (about 3 million points). Actually I've 3 vectors with the same dimension and I use to plot in the following way. import matplotlib.pyplot as plt import numpy as…
Nicola Vianello
  • 1,916
  • 6
  • 21
  • 26
24
votes
3 answers

How do I make the width of the title box span the entire plot?

consider the following pandas series s and plot import pandas as pd import numpy as np s = pd.Series(np.random.lognormal(.001, .01, 100)) ax = s.cumprod().plot() ax.set_title('My Log Normal Example', position=(.5, 1.02), …
piRSquared
  • 285,575
  • 57
  • 475
  • 624
24
votes
1 answer

Running matplotlib in tkinter

I have this beautiful sphere I made in matplotlib. How would I go about putting it in a tkinter frame widget? It'd be nice to be able to integrate it into an existing tkinter GUI. Also is it possible to rid of the menu bar below the display? I have…
rectangletangle
  • 50,393
  • 94
  • 205
  • 275
24
votes
2 answers

How to change the color of a single bar if condition is True

Is it possible to change only the color of a single bar in a graph made by matplotlib? Let's say I've evaluation 1 to 10 and for each one I've a graph generate when the user choice the evaluation. For each evaluation one of this boys will win. So…
psoares
  • 4,733
  • 7
  • 41
  • 55
24
votes
1 answer

AttributeError: Unknown property legend in seaborn

The seaborn stripplot has a function which allows hue. Using the example from https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.stripplot.html import seaborn as sns sns.set_style("whitegrid") tips = sns.load_dataset("tips") ax =…
ShanZhengYang
  • 16,511
  • 49
  • 132
  • 234
24
votes
1 answer

How to smooth by interpolation when using pcolormesh?

I have a basemap of the world, and it's filled with data (lintrends_mean) using pcolormesh. Because the data has relatively large grid boxes, I'd like to smooth the plot. However, I can't figure out how to do this. Setting shading='gouraud' in the…
Cebbie
  • 1,741
  • 6
  • 23
  • 37
24
votes
4 answers

Get data points from Seaborn distplot

I use sns.distplot to plot a univariate distribution of observations. Still, I need not only the chart, but also the data points. How do I get the data points from matplotlib Axes (returned by distplot)?
tesgoe
  • 1,012
  • 3
  • 10
  • 19
24
votes
7 answers

how to plot ohlc candlestick with datetime in matplotlib?

I need to plot trade data every 5 minutes (one candle) Here is what I have so far: from matplotlib.finance import candlestick2_ohlc fig, ax =…
dindom
  • 583
  • 2
  • 4
  • 17
24
votes
2 answers

plot several image files in matplotlib subplots

I would like to create a matrix subplot and display each BMP files, from a directory, in a different subplot, but I cannot find the appropriate solution for my problem, could somebody helping me?. This the code that I have: import os, sys from PIL…
hammu
  • 463
  • 1
  • 4
  • 10
24
votes
5 answers

Change size/alpha of markers in the legend box

What is the most convenient way to enlarge and set the alpha value of the markers (back to 1.0) in the legend box? I'm also happy with big coloured boxes. import matplotlib.pyplot as plt import numpy as np n = 100000 s1 = np.random.normal(0, 0.05,…
tamasgal
  • 24,826
  • 18
  • 96
  • 135
24
votes
7 answers

How can I make a video from array of images in matplotlib?

I have a couple of images that show how something changes in time. I visualize them as many images on the same plot with the following code: import matplotlib.pyplot as plt import matplotlib.cm as cm img = [] # some array of images fig =…
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
24
votes
2 answers

Drawing circles on image with Matplotlib and NumPy

I have NumPy arrays which hold circle centers. import matplotlib.pylab as plt import numpy as np npX = np.asarray(X) npY = np.asarray(Y) plt.imshow(img) // TO-DO plt.show() How can I show circles at the given positions on my image?
orkan
  • 512
  • 1
  • 4
  • 18
24
votes
2 answers

matplotlib plot_date() add vertical line at specified date

My data is stored as a pandas dataframe. I have created a chart of date (object format) vs. percentile (int64 format) using the plot_date() function in matplotlib and would like to add some vertical lines at pre-specified dates. I have managed to…
annievic
  • 401
  • 1
  • 3
  • 7