is there a way to print a plot from matplotlib,either with a command or from the plot window itself ? I know i could save it and then print,but I am looking for something more automated.Thanks.
To draw multiple plots using the subplot() function from the pyplot module, you need to perform two steps: First, you need to call the subplot() function with three parameters: (1) the number of rows for your grid, (2) the number of columns for your grid, and (3) the location or axis for plotting.
In Matplotlib, we can draw multiple graphs in a single plot in two ways. One is by using subplot() function and other by superimposition of second graph on the first i.e, all graphs will appear on the same plot.
You could save the figure as a pdf, then use subprocess
to print the pdf. On *nix, lpr
could be used:
import matplotlib.pyplot as plt
import numpy as np
import subprocess
import shlex
n=20
x=np.linspace(0,np.pi,n)
y=np.sin(x)
plt.plot(x,y)
fname='/tmp/test.pdf'
plt.savefig(fname)
proc=subprocess.Popen(shlex.split('lpr {f}'.format(f=fname)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With