I compiled matplotlib on a mac running snow leopard only to find that when I import matplotlib.pyplot I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py", line 6, in <module>
fro...
The following sample code will produce a basic line plot with no axis and save it as an SVG file:
import matplotlib.pyplot as plt
plt.axis('off')
plt.plot([1,3,1,2,3])
plt.plot([3,1,1,2,1])
plt.savefig("out.svg", transparent = True)
Question 1) How do I set the resolution / dimensions off the image?
Qestiion 2) There is padding on al...
I have one y variable, which I am trying to plot against two related x axes, on the top and bottom of the figure (e.g. y="number of things in cube", x1="side length of cube", x2="volume of cube"). I have y, x1, x2 in numpy arrays. The relationship between my x1 and x2 is one-to-one and monotonic, but not simple, and they increase in diff...
Trying to plot a spectrum, ie, velocity versus intensity, with lower x axis = velocity, on the upper twin axis = frequency
The relationship between them (doppler formula) is
f = (1-v/c)*f_0
where f is the resulting frequency, v the velocity, c the speed of light, and f_0 the frequency at v=0, ie. the v_lsr.
I have tried to solve ...
I am trying to change the matplotlib font to helvetica, which I'd like to use in a PDF plot. I try the following:
import matplotlib
matplotlib.use('PDF')
import matplotlib.pylab as plt
from matplotlib import rc
plt.rcParams['ps.useafm'] = True
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['pdf.fonttype'] ...
Hello All,
Running:
Windows Vista
Python 2.6
Matplotlib 0.99.3
The following script using draw() in matplotlib seems to work all right until almost anything momentarily interferes with the plot window.
import pylab as p
import time
try:
p.ion()
fig = p.figure()
subplt = fig.add_subplot(111, aspect='equal')
subplt.s...
I'm trying to use matplotlib to prepare some figures for publication. In order to make the font sizes match the text of the manuscript I'm trying to create the figure in the final size to begin with, so that I avoid scaling the figure when inserting it into the manuscript.
The problem I'm having is that as the figure is then pretty smal...
I create a figure and fill it with a couple of subplots.
As new data arrives, I'd like to draw it on a given subplot.
How do I switch between subplots so that I don't have to create new subplot objects each time?
Example:
from matplotlib.pyplot import figure,
figure()
subplot(2,1,1)
subplot(2,1,2)
# now go back and plot something o...
When I run this code
from pylab import *
figure()
ax1 = subplot(121)
plot([1, 2, 3], [1, 2, 3])
subplot(122, sharex=ax1, sharey=ax1)
plot([1, 2, 3], [1, 2, 3])
draw()
show()
I get two subplots which are "squished" in the X-dimension. How do I get these subplots such that the height of the Y-axis equals the width of the X-axis, for bo...
I am having trouble installing matplotlib on mac os 10.6, so I used macports and installed all dependencies it needed, which is great, but on top of it a new python version. Now I have two python versions and that bothers me. The matplotlib is working fine on the macport python, and the rest of my stuff is with the default python.
What ...
How can I plot the empirical CDF of an array of numbers in matplotlib in Python? I'm looking for the cdf analog of pylab's "hist" function.
One thing I can think of is:
from scipy.stats import cumfreq
a = array([...]) # my array of numbers
num_bins = 20
b = cumfreq(a, num_bins)
plt.plot(b)
Is that correct though? Is there an easie...
Dear All,
I need to create a stacked bar chart using matplotlib. Each bar should be a stack of the parameters I am measuring. However, I want it to be interactive or dynamic so as when I click on one of the parameters (A,B,C) for example in the legend, it should make that parameter at the bottom of the stack so as we could have a better...
If I feed several x/y sets to matplotlib.pyplot.plot, how does annotate decide how to correlate the xy value to one of the sets? Is there an assumption that all the sets are scaled the same way?
plt.plot(clist, plist, 'g', clist, rlist, 'r', clist, flist, 'b')
plt.annotate("%d chars F=%f" % (threshold_c, threshold_f), xy=(threshold_c,...
I need to get a plot that fits the data automatically using matplotlib. This is the code I was given:
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
....
lines = LineCollection(mpl.line_holder, colors=mpl.colorholder , linestyle='solid')
plt.axes().add_collection(lines)
plt.axes().set_aspect('equal', '...
I have two graphs with in one image, each with 5 points. Their value on the X axis is not important, all that I require is that they're all equally distributed on it.
import matplotlib.pyplot as plt
data = [43,51,44,73,60]
data2 = [34,25,42,53,61]
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.plot(data, '-o', color='#000000', lw=...
I have a class which I use to plot things then save them to a file. Here's a simplified version of it:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
class Test():
def __init__(self, x, y, filename):
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.plot(x, y, 'D', color='red')
...
I am using scipy-cluster in my application. It provides a function to plot a dendrogram of the hierarchical cluster tree. Looking at the source I find that it eventually plots the dendrogram by calling draw_if_interactive. As one would expect, this works fine in an interactive session, but when I run the script non-interactively, a windo...
Hello,
I've created a simple hexbin plot with matplotlib.pyplot. I haven't changed any default settings. My x-axis information ranges from 2003 to 2009, while the y values range from 15 to 35. Rather than writing out 2003, 2004, etc., matplotlib collapses it into 0, 1, 2, ... + 2.003e+03. Is there a simple way to force matplotlib to...
I would like to know how to simply reverse the color order of a given colormap in order to use it with plot_surface.
...
Hi,
I am struggling with the following issue. I need to generate reports that consists of a collection of charts. All these charts, except one, are made using Matplotlib default backend (TkAgg). One chart needs to be made using the Cairo backend, the reason is that I am plotting an igraph graph and that can only be plotted using Cairo. ...