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
2 answers

How to show minor tick labels on log-scale with Matplotlib

Does anyone know how to show the labels of the minor ticks on a logarithmic scale with Python/Matplotlib?
Tomas
  • 503
  • 2
  • 7
  • 15
23
votes
2 answers

Delaunay Triangulation of points from 2D surface in 3D with python?

I have a collection of 3D points. These points are sampled at constant levels (z=0,1,...,7). An image should make it clear: These points are in a numpy ndarray of shape (N, 3) called X. The above plot is created using: import matplotlib.pyplot as…
Matt Hancock
  • 3,870
  • 4
  • 30
  • 44
23
votes
3 answers

import matplotlib.pyplot gives ImportError: dlopen(…) Library not loaded libpng15.15.dylib

I am aware that this exact same question has been asked before. I did follow the instructions given in the answer there, and it didn't solve my problem (and I don't have enough reputation to just comment on the Q or A in that thread). Anyway, here's…
Russell Richie
  • 421
  • 1
  • 5
  • 15
23
votes
3 answers

Multiple font sizes in plot title

I'm plotting in an IPython IDE using Matplotlib.pyplot and added a title with: plt.title('Mean WRFv3.5 LHF\n(September 16 - October 30, 2012)', fontsize=40) However, I want the first line to be size 40 and the second line to be size 18. Is that…
Aaron Rosenberg
  • 333
  • 1
  • 3
  • 8
23
votes
4 answers

Display the maximum surface in matplotlib?

I'm plotting multiple surfaces on the same figure using matplotlib, and I'd like to see only the topmost surface, as matlab shows. Matlab 3D view: Matlab top view: Matplotlib 3D view: Matplotlib top view: How can I get Matplotlib to show a…
Nick Sweet
  • 2,030
  • 3
  • 31
  • 48
23
votes
3 answers

kmeans scatter plot: plot different colors per cluster

I am trying to do a scatter plot of a kmeans output which clusters sentences of the same topic together. The problem i am facing is plotting points that belongs to each cluster a certain color. sentence_list=["Hi how are you", "Good morning" ...] #i…
jxn
  • 7,685
  • 28
  • 90
  • 172
23
votes
1 answer

How to project filled contour onto a 3d surface plot

I'm simply trying to plot a surface and its contour in 3D, exactly as in this example. This is the code I'm using to do it: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d from matplotlib import cm import numpy def…
pceccon
  • 9,379
  • 26
  • 82
  • 158
23
votes
2 answers

Position 5 subplots in Matplotlib

I would like to position 5 subplots such that there are three of top and two at the bottom but next to each other. The current code gets close but I would like the final result to look like the following (ignore gray lines): import…
Rohit
  • 5,840
  • 13
  • 42
  • 65
23
votes
2 answers

plotting multiple plots generated inside a for loop on the same axes python

My code is as follows, the problem is instead of having one plot, I get 242 plots. I tried putting the plt.show() outside the loop, it didn't work. import numpy as np import matplotlib.pyplot as plt import csv names = list() with…
Michael Hlabathe
  • 231
  • 1
  • 2
  • 3
23
votes
3 answers

Python - animation with matplotlib.pyplot

How can one create animated diagrams using popular matplotlib library? I am particularly interested in animated gifs.
psihodelia
  • 29,566
  • 35
  • 108
  • 157
23
votes
1 answer

Scatter plot colorbar - Matplotlib

I'm trying to show a color bar of my scatter plot but I'm keep getting the error: TypeError: You must first set_array for mappable This is what I'm doing to plot: # Just plotting the values of data that are nonzero x_data = numpy.nonzero(data)[0]…
pceccon
  • 9,379
  • 26
  • 82
  • 158
23
votes
1 answer

Parameters required by bar3d with python

I want to make a 3d bar plot with python, and I discovered the bar3d function. Here is the documentation. I do not understand which values I have to pass over to bar3d, documentation only tells me something about the appropriate format. I have found…
PKlumpp
  • 4,913
  • 8
  • 36
  • 64
23
votes
3 answers

boxplot using precalculated (summary) statistics

I need to do a boxplot (in Python and matplotlib) but I do not have the original "raw" data. What I have are precalculated values for max, min, mean, median and IQR (normal distribution) but still I'd like to do a boxplot. Of course plotting…
Nicke N
  • 233
  • 1
  • 2
  • 5
23
votes
4 answers

How can I plot the probability density function for a fitted Gaussian mixture model under scikit-learn?

I'm struggling with a rather simple task. I have a vector of floats to which I would like to fit a Gaussian mixture model with two Gaussian kernels: from sklearn.mixture import GMM gmm = GMM(n_components=2) gmm.fit(values) # values is numpy…
Louis Thibault
  • 20,240
  • 25
  • 83
  • 152
23
votes
1 answer

matplotlib: log transform counts in hist2d

Is there a simple way to get log transformed counts when plotting a two dimensional histogram in matplotlib? Unlike the pyplot.hist method, the pyplot.hist2d method does not seem to have a log parameter. Currently I'm doing the following: import…
cel
  • 30,017
  • 18
  • 97
  • 117
1 2 3
99
100