Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent images from appearing on the screen in Matplolib? Python
    primarykey
    data
    text
    <p>I have a quick question I am trying to solve. I have a script that processes about 2000 files, generates images and saves images to either PDF or image format. But I am not able to prevent images from appearing on the screen. I read and researched but couldn't solve my problem. I assume there is something wrong with my backend set up in Matplotlib. But I am not an expert in that. I tried using matplotlib.use('Agg') as stated on the website but it didnt help. So, if you could help me figure out whats going on wrong I d appreciate that. Thanks a lot!</p> <p>System: Ubuntu 13.04 Matplotlib: 1.2.1 Python 2.7.4</p> <p>Here is how importing part of my script looks:</p> <pre><code>from matplotlib.backends.backend_pdf import PdfPages import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.ticker import MultipleLocator, AutoMinorLocator, ScalarFormatter from pylab import * </code></pre> <p>EDIT: posting more code. It's just a part of it. I have a function:</p> <pre><code>def plot_vi(t, s1, s2, s3, charttitle, chartnote, celllocation, filename): fig = plt.figure(figsize=(16, 12)) ax1 = fig.add_subplot(111) l1, = ax1.plot(t, s1, 'r-', linewidth=0.7) l2, = ax1.plot(t, s3, '-', linewidth=0.7, color='#00ff00') ax1.set_xlabel('Test Time (hours)') # Make the y-axis label and tick labels match the line color. ax1.set_ylabel('Voltage (Volts)', color='r') for tl in ax1.get_yticklabels(): tl.set_color('r') ax2 = ax1.twinx() l3, = ax2.plot(t, s2, 'b-', linewidth=0.7) ax2.set_ylabel('Current (Amps)', color='b') for tl in ax2.get_yticklabels(): tl.set_color('b') minorLocator = AutoMinorLocator() ax2.xaxis.set_minor_locator(minorLocator) majorLocator = MultipleLocator(1) minorLocator = MultipleLocator(0.2) ax2.yaxis.set_major_locator(majorLocator) ax2.yaxis.set_minor_locator(minorLocator) majorLocator = MultipleLocator(0.1) minorLocator = MultipleLocator(0.02) ax1.yaxis.set_major_locator(majorLocator) ax1.yaxis.set_minor_locator(minorLocator) ax1.xaxis.grid(color='gray') ax1.yaxis.grid(color='gray') lgd = legend([l1, l3, l2], ['voltage', 'current', 'auxiliary'], bbox_to_anchor=(1.05, 1), loc=2) title(charttitle, fontsize=16) figtext(0.01, 0.027, chartnote, color='#707070') figtext(0.01, 0.01, celllocation, color='#707070') fig.subplots_adjust(right=0.85) plt.savefig(filename, dpi=100)plot_vi(t, s1, s2, s3, ChartTitle, ChartNote, CellLocation, PLOTFILENAME) plt.savefig(pp, format='pdf') </code></pre> <p>Then I ran that function:</p> <pre><code> plot_vi(t, s1, s2, s3, ChartTitle, ChartNote, CellLocation, PLOTFILENAME) plt.savefig(pp, format='pdf') </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload