I have time series data (signal) of different length that I would like to plot without any margins between scale and signal.
Goal: plot each signal so (physical) printing of the plot will show every single data point. The plot shall be saved to a file.
Given:
- printer with 600 dpi maximum printing resolution.
- signals with different number of data points (from 30000 to 100000).
example of signal:
import numpy as np
Fs = 512
# Create random signal
np.random.seed(1)
data = [np.random.uniform(-10000, 20000) for i in range(5*Fs)]
If I just plot it with matplotlib:
import matplotlib.pyplot as plt
plt.figure(figsize=(len(data)/600,2)) # divide by 600 which is dpi resolution of printer
plt.plot(data, color = "black", linewidth = 1.0)
plt.show()
I do not want any white space between the first data point and the Y axis or between the last data point and the right border. The label of the Y axis should also not interfere with the plot's size, so its width should also be considered.
How do I accomplish to have every single point printed?


plt.xlim([...])andplt.ylim([...])to exactly match your data. If you really want every point printed you should probably save the plot in a vector-graphics format, and then print sufficiently large. First, I don't really see why you'd want this. Second, I don't think you can ever be sure, your printer's driver and its software might also influence what is actually printed. - Tom de Geusplt.margins(0,0)to remove the automatic margins - DavidGmarginssolves this problem (probably only part of it). On the other hand its totally unclear what "print every single point" means if you have 100000 points. If you have 100000 points divided 600 dpi = 166 inch = 4.20 meters. There is no paper that measures 4 meters. So in that sense I still think this question is not answerable. - ImportanceOfBeingErnest