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

Show the values in the grid using matplotlib

I m trying to generate heatmaps for the some data and my code is shown below: data = [['basis', 2007, 2008], [1, 2.2, 3.4], [2, 0, -2.2], [3, -4.1, -2.5], [4, -5.8, 1.2], [5, -5.4, -3.6], [6, 1.4,…
sunil_mlec
  • 642
  • 1
  • 8
  • 20
24
votes
3 answers

matplotlib set shared axis

Using matplotlib, it seems the only time to set the sharex or sharey axis parameters are during sub_plot creation (add_subplot(), subplot(), subplots()). For an axes class there are methods for getting axis sharing (get_shared_x_axes(),…
CNK
  • 1,053
  • 2
  • 11
  • 17
24
votes
5 answers

Peak detection in a noisy 2d array

I'm trying to get python to return, as close as possible, the center of the most obvious clustering in an image like the one below: In my previous question I asked how to get the global maximum and the local maximums of a 2d array, and the answers…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
24
votes
7 answers

Bland-Altman plot in Python

Is it possible to make a Bland-Altman plot in Python? I can't seem to find anything about it. Another name for this type of plot is the Tukey mean-difference plot. Example:
Olivier_s_j
  • 5,490
  • 24
  • 80
  • 126
24
votes
1 answer

Linestyle in matplotlib step function

Is it possible to set the linestyle in a matplotlib step function to dashed, dotted, etc.? I've tried: step(x, linestyle='--'), step(x, '--') But it did not help.
user2061207
  • 255
  • 1
  • 3
  • 7
24
votes
2 answers

Multiple legends in for-loop

The following program executes fine but only one legend is displayed. How can I have all the four legends displayed? kindly see the image attached. import matplotlib.pyplot as plt dct = {'list_1' : [1,2,4,3,1],'list_2' : [2,4,5,1,2],'list_3' :…
brain storm
  • 30,124
  • 69
  • 225
  • 393
24
votes
2 answers

How to draw intersecting planes?

I want to use matplotlib to draw more or less the figure I attached below, which includes the two intersecting planes with the right amount of transparency indicating their relative orientations, and the circles and vectors in the two planes…
nye17
  • 12,857
  • 11
  • 58
  • 68
24
votes
3 answers

Why matplotlib does not plot?

I started to learn MatPlotLib using this tutorial for beginners. Here is the first example. from pylab import * X = np.linspace(-np.pi, np.pi, 256,endpoint=True) C,S = np.cos(X), np.sin(X) If I write these 3 lines into my python file and execute it…
Roman
  • 124,451
  • 167
  • 349
  • 456
24
votes
2 answers

Plot 2-dimensional NumPy array using specific columns

I have a 2D numpy array that's created like this: data = np.empty((number_of_elements, 7)) Each row with 7 (or whatever) floats represents an object's properties. The first two for example are the x and y position of the object, the others are…
tamacun
  • 421
  • 1
  • 4
  • 9
24
votes
5 answers

Matplotlib coord. sys origin to top left

How can I flip the origin of a matplotlib plot to be in the upper-left corner - as opposed to the default lower-left? I'm using matplotlib.pylab.plot to produce the plot (though if there is another plotting routine that is more flexible, please let…
Nate
  • 768
  • 3
  • 9
  • 17
24
votes
3 answers

Fill countries in python basemap

Hi I am trying to plot a map using pythons basemap with some countries filled in a certain colour. Is there a quick and easy solution out there??
red_tiger
  • 1,402
  • 3
  • 16
  • 32
24
votes
5 answers

matplotlib won't draw python3

I installed matplotlib successfully inside a virtualenv. Now I'm trying to get it to draw. I know how to change the backend, but I'm having a whole lot of trouble figuring out what to change it to. Has anyone managed to get it totally working with…
Sheena
  • 15,590
  • 14
  • 75
  • 113
24
votes
4 answers

Displaying Matplotlib Navigation Toolbar in Tkinter via grid

I'm developing a small Tkinter GUI to draw matplotlib-plots. (It contains a few Entries and assembles the plot according to their content.) I have designed my plotting widget according to…
CodingCat
  • 4,999
  • 10
  • 37
  • 59
24
votes
2 answers

matplotlib.pyplot How to name different lines in the same plot?

Think about doing this: import matplotlib.pyplot as plt plt.plot(x_A,y_A,'g--') plt.plot(x_B,y_B,'r-o') plt.show() How would you go about giving both lines different names, i.e. like Microsoft Excel would do it?
erikbstack
  • 12,878
  • 21
  • 81
  • 115
23
votes
4 answers

Drawing a huge graph with networkX and matplotlib

I am drawing a graph with around 5K nodes in it using networkX and matplotlib. The GTK window by matplotlib has tools to zoom and visualise the graph. Is there any way, I can save a magnified version for proper visualisation later? import…
Nihar Sarangi
  • 4,845
  • 8
  • 27
  • 32