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
23
votes
1 answer

Dates in the xaxis for a matplotlib plot with imshow

So I am new to programming with matplotlib. I have created a color plot using imshow() and an array. At first the axis were just the row and column number of my array. I used extent = (xmin,xmax,ymin,ymax) to get the x-axis in unix time and…
user3546200
  • 269
  • 1
  • 3
  • 10
23
votes
7 answers

How to disable xkcd in a matplotlib figure?

You turn on xkcd style by: import matplotlib.pyplot as plt plt.xkcd() But how to disable it? I try: self.fig.clf() But it won't work.
alwbtc
  • 28,057
  • 62
  • 134
  • 188
23
votes
3 answers

Align twinx tick marks

Is it possible to make a plot with two independent y-axes such that the tick marks align? Below is an example of half of the solution. I've doubled the y-axis using twinx, but the tick marks aren't aligned and the gridlines form an awkward pattern…
juniper-
  • 6,262
  • 10
  • 37
  • 65
23
votes
1 answer

remove italics in latex subscript in matplotlib

I would like to remove the italics font that appears when I use subscripts in labels. For example, the "Teff" in the x-label has "eff" in italics. I would like latex not render it in such a way. Generally, in latex this can be achieved with the…
Rohit
  • 5,840
  • 13
  • 42
  • 65
23
votes
2 answers

Correcting matplotlib colorbar ticks

I've placed a color bar alongside a choropleth map. Because the data being plotted are discrete rather than continuous values, I've used a LinearSegmentedColormap (using the recipe from the scipy cookbook), which I've initialised with my max counted…
urschrei
  • 25,123
  • 12
  • 43
  • 84
23
votes
5 answers

Matplotlib imshow: Data rotated?

I was trying to plot some data with scatter. My code is import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np from scipy.interpolate import griddata data = np.loadtxt('file1.txt') x = data[:,0] y = data[:,1] z =…
Tengis
  • 2,721
  • 10
  • 36
  • 58
23
votes
1 answer

matplotlib using twinx and twiny together (like twinxy)

Can I have both twinx and twiny together (i.e. something like twinxy)? I want to put a CDF on a bar plot where the X axis of the bar plot is in log-scale. I cannot make the Ys together, because the bar plot y range is very large comparing [0,1] for…
Amir
  • 5,996
  • 13
  • 48
  • 61
23
votes
6 answers

Matplotlib requirements with pip install in virtualenv

I have a requirements.txt file like this: numpy matplotlib When I try pip install -r requirements.txt inside a new virtualvenv, I get this: REQUIRED DEPENDENCIES numpy: no * You must install numpy 1.1 or later to…
msampaio
  • 3,394
  • 6
  • 33
  • 53
23
votes
1 answer

How do I convert (or scale) axis values and redefine the tick frequency in matplotlib?

I am displaying a jpg image (I rotate this by 90 degrees, if this is relevant) and of course the axes display the pixel coordinates. I would like to convert the axis so that instead of displaying the pixel number, it will display my unit of choice -…
Dave
  • 6,184
  • 8
  • 26
  • 28
23
votes
2 answers

Automatically setting y-axis limits for bar graph using matplotlib

Here's an example of graphing large values. import matplotlib.pyplot as plt x = [1,2,3,4,5] y = [1000, 1002, 1001, 1003, 1005] plt.bar(x,y) plt.show() The y-axis starts at 0, so the bars all look equal. I know you can use plt.ylim to manually set…
user1473483
  • 305
  • 1
  • 3
  • 7
23
votes
3 answers

Matplotlib markers disappear when edgecolor = 'none'

I'm trying to make a scatter plot of some PCA data. I do some pretty typical code: plt.plot(pca[:,0], pca[:,1], '.',ms=3, markerfacecolor = self.colors[k], markeredgecolor = 'none') I want it to show just the marker face color with no…
Mat Leonard
  • 253
  • 1
  • 2
  • 6
22
votes
1 answer

Why doesn't pyplot.show() work?

Possible Duplicate: matplotlib does not show my drawings although I call pyplot.show() I'm a newbie to Matplotlib and have encountered this problem. I'm using a Ubuntu system. I started with Matplotlib 0.99 and realized that I really need the new…
user1248468
  • 221
  • 1
  • 2
  • 3
22
votes
2 answers

How to create a polar contour plot

Update: I've done a full write-up of the way I found to do this on my blog at http://blog.rtwilson.com/producing-polar-contour-plots-with-matplotlib/ - you may want to check there first. I'm trying to plot a polar contour plot in matplotlib. I've…
robintw
  • 27,571
  • 51
  • 138
  • 205
22
votes
2 answers

How to determine which points are inside of a polygon and which are not (large number of points)?

I've got a large set of data points (100,000+) stored in a 2-dimensional numpy array (1st column: x coordinates, 2nd column: y coordinates). I've also got several 1-dimensional arrays storing additional information for each data point. I'd now like…
AbuBakr
  • 968
  • 2
  • 11
  • 22
22
votes
4 answers

matplotlib -- interactively select points or locations?

In R, there is a function locator which is like Matlab's ginput where you can click on the figure with a mouse and select any x,y coordinate. In addition, there is a function called identify(x,y) where if you give it a set of points x,y that you…
hatmatrix
  • 42,883
  • 45
  • 137
  • 231
1 2 3
99
100