disable matplotlib toolbar
Make sure to call mpl.rcParams[‘toolbar’] = ‘None’ before you instantiate any figures.
Make sure to call mpl.rcParams[‘toolbar’] = ‘None’ before you instantiate any figures.
Could you provide an example? Is this what you want: import datetime import numpy as np import pylab as plt import matplotlib fig = plt.figure() ax = fig.add_subplot(111) x = np.linspace(0, 300) # 5 minutes y = np.random.random(len(x)) ax.plot(x, y) def timeTicks(x, pos): d = datetime.timedelta(seconds=x) return str(d) formatter = matplotlib.ticker.FuncFormatter(timeTicks) ax.xaxis.set_major_formatter(formatter) plt.show() It uses … Read more
I think you’re going to need separate lines for each segment: import numpy as np import matplotlib.pyplot as plt x, y = np.random.random(size=(2,10)) for i in range(0, len(x), 2): plt.plot(x[i:i+2], y[i:i+2], ‘ro-‘) plt.show() (The numpy import is just to set up some random 2×10 sample data)
You can save an image as ‘png’ and use the python imaging library (PIL) to convert this file to ‘jpg’: import Image import matplotlib.pyplot as plt plt.plot(range(10)) plt.savefig(‘testplot.png’) Image.open(‘testplot.png’).save(‘testplot.jpg’,’JPEG’) The original: The JPEG image:
imshow can take an array of [r, g, b] entries. So you can convert the absolute values to intensities and phases – to hues. I will use as an example complex numbers, because for it it makes the most sense. If needed, you can always add numpy arrays Z = X + 1j * Y. … Read more
I bumped into this link found here, which answers my problem. It seems that after turning on interactive mode through plt.ion(), pyplot needs to be paused temporarily for it to update/redraw itself through plt.pause(0.0001). Here is what I did and it works! >>> import matplotlib.pyplot as plt >>> import numpy as np >>> plt.ion() >>> … Read more
Just iterate through the axes tied to the figure, set the active axes to the iterated object, and modify: for ax in fig.axes: matplotlib.pyplot.sca(ax) plt.xticks(rotation=90)
As of matplotlib v1.4.0rc4, a remove method has been added to the legend object. Usage: ax.get_legend().remove() or legend = ax.legend(…) … legend.remove() See here for the commit where this was introduced.
You simply need to re-assign ax.format_coord. See this example from the documentation. (code lifted directly from example) “”” Show how to modify the coordinate formatter to report the image “z” value of the nearest pixel given x and y “”” import numpy as np import matplotlib.pyplot as plt import matplotlib.cm as cm X = 10*np.random.rand(5,3) … Read more
twin axis Adding a second y axis can be done by creating a twin axes, ax2 = ax.twinx(). The scale of this axes can be set using its limits, ax2.set_ylim(y2min, y2max). The values of y2min, y2max can be calculated using some known relationship (e.g. implemented as a function) from the limits of the left axis. … Read more