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

two (or more) graphs in one plot with different x-axis AND y-axis scales in python

I want 3 graphs on one axes object, for example: #example x- and y-data x_values1=[1,2,3,4,5] y_values1=[1,2,3,4,5] x_values2=[-1000,-800,-600,-400,-200] y_values2=[10,20,39,40,50] x_values3=[150,200,250,300,350] y_values3=[10,20,30,40,50] #make…
Anton Rodenhauser
  • 441
  • 1
  • 3
  • 11
23
votes
2 answers

plt.imshow shows color images for grayscale images in IPython

I have the following RGB image imRGB import cv2 import matplotlib.pyplot as plt #Loading the RGB image imRGB = cv2.imread('*path*') imRGB.shape >>(128L, 128L, 3L) #plotting plt.imshow(imRGB) I convert this to a grayscale image imGray imGray =…
akilat90
  • 5,436
  • 7
  • 28
  • 42
23
votes
2 answers

Ordering boxplot x-axis in seaborn

My dataframe round_data looks like this: error username task_path 0 0.02 n49vq14uhvy93i5uw33tf7s1ei07vngozrzlsr6q6cnh8w... 39.png 1 0.10 …
amaatouq
  • 2,297
  • 5
  • 29
  • 50
23
votes
2 answers

How to insert scale bar in a map in matplotlib

Any ideas on how can I insert a scale bar in a map in matplotlib that shows the length scale? something like the one I have attached. Or maybe any ideas on measuring and showing distances automatically (not drawing an arrow and writing the distance…
Behnam
  • 501
  • 1
  • 5
  • 21
23
votes
5 answers

Plotting mplot3d / axes3D xyz surface plot with log scale?

I've been looking high and low for a solution to this simple problem but I can't find it anywhere! There are a loads of posts detailing semilog / loglog plotting of data in 2D e.g. plt.setxscale('log') however I'm interested in using log scales on a…
Mark
  • 1,277
  • 3
  • 13
  • 27
23
votes
3 answers

Difference between plt.imshow and cv2.imshow?

Why is there a difference in the output image when calling the same image using plt.imshow & cv2.imshow()? Here is my code: import cv2 import numpy as np from matplotlib import pyplot as plt src=cv2.imread('fruits1.jpg') # Source…
Aman Garg
  • 343
  • 1
  • 2
  • 6
23
votes
5 answers

Matplotlib can't find font installed in my Linux machine

I am trying to draw an xkcd-style plot with matplotlib (ver. 1.4.2) under Python 3. When I try to run: import matplotlib.pyplot as plt plt.xkcd() plt.plot([1,2,3,4], [1,4,9,16], 'bo') plt.axis([0, 6, 0, 20]) plt.show() It opens an empty window…
Pierre B
  • 654
  • 2
  • 6
  • 15
23
votes
2 answers

Combine picture and plot with Python Matplotlib

I have a plot which has timestamps on the x-axis and some signal data on the y-axis. As a documentation I want to put timestamped pictures in relation to specific points in the plot. Is it possible to draw a line in a plot to a picture in a sequence…
Sney
  • 2,486
  • 4
  • 32
  • 48
23
votes
3 answers

Adding units to heatmap annotation in Seaborn

I am trying to show a table of percentages as a heatmap in Seaborn: sns.heatmap(S, annot=True, fmt=".1f", linewidths=1.0, square=1) However, I'd like the percent sign to appear after each number in the heatmap annotations. The fmt flag only seems…
Jsl
  • 842
  • 1
  • 5
  • 10
23
votes
2 answers

standard deviation and errors bars in seaborn tsplot function in Python

How does Seaborn compute its error bars? example: import numpy as np; np.random.seed(22) import seaborn as sns; sns.set(color_codes=True) x = np.linspace(0, 15, 31) data = np.sin(x) + np.random.rand(10, 31) + np.random.randn(10, 1) ax =…
lgd
  • 1,472
  • 5
  • 17
  • 35
23
votes
6 answers

How to get high and low envelope of a signal

I have quite a noisy data, and I am trying to work out a high and low envelope to the signal. It is kind of like this example in MATLAB in "Extracting Peak Envelope". Is there a similar function in Python that can do that? My entire project has been…
user5224720
23
votes
1 answer

split violinplot in seaborn with hue parameter

I am trying to make a violinplot using only the y and hue parameters in seaborn (x data variable is defined as None). Using a similar example as in the documentation I have done: tips = sns.load_dataset("tips") sns.violinplot(y="total_bill",…
gypaetus
  • 6,873
  • 3
  • 35
  • 45
23
votes
1 answer

How to plot result of np.histogram with matplotlib analog to plt.hist

I like to plot my histograms like this: data = [-0.5, 0.5, 0.5, 0.5, 1.5, 2.1, 2.2, 2.3, 2.4, 2.5, 3.1, 3.2] plt.hist(data, bins=5, range=[-1, 4], histtype='step') Now, when I have somehow large input data (larger than my memory), I need to…
Dominik Neise
  • 1,179
  • 1
  • 10
  • 23
23
votes
5 answers

Seaborn configuration hides default matplotlib

Seaborn provides of a handful of graphics which are very interesting for scientifical data representation. Thus I started using these Seaborn graphics interspersed with other customized matplotlib plots. The problem is that once I do: import seaborn…
joaquin
  • 82,968
  • 29
  • 138
  • 152
23
votes
2 answers

python - uploading a plot from memory to s3 using matplotlib and boto

This is my working script that generates a plot, saves it locally to disk, uploads to S3 and deletes the file: plt.figure(figsize=(6,6)) plt.plot(x, y, 'bo') plt.savefig('file_location') conn = boto.s3.connect_to_region( …
GuyB7
  • 606
  • 1
  • 6
  • 15