Save plot to image file instead of displaying it using Matplotlib

While the question has been answered, I’d like to add some useful tips when using matplotlib.pyplot.savefig. The file format can be specified by the extension: from matplotlib import pyplot as plt plt.savefig(‘foo.png’) plt.savefig(‘foo.pdf’) Will give a rasterized or vectorized output respectively, both which could be useful. In addition, there’s often an undesirable, whitespace around the … Read more

Changing the “tick frequency” on x or y axis in matplotlib

You could explicitly set where you want to tick marks with plt.xticks: plt.xticks(np.arange(min(x), max(x)+1, 1.0)) For example, import numpy as np import matplotlib.pyplot as plt x = [0,5,9,10,15] y = [0,1,2,3,4] plt.plot(x,y) plt.xticks(np.arange(min(x), max(x)+1, 1.0)) plt.show() (np.arange was used rather than Python’s range function just in case min(x) and max(x) are floats instead of ints.) … Read more

plot multiple columns in R [closed]

Following works: > > ddf HostName iops port_No tag1 tag2 timestamp 1 Hostx 12 ab1 tag1 tag2 ts1 2 Hostx 20 ab1 tag1 tag2 ts2 3 Hostx 100 ab1 tag1 tag2 ts3 4 Hostx 32 abcd tag1 tag2 ts1 5 Hostx 52 abcd tag1 tag2 ts2 6 Hostx 62 abcd tag1 tag2 ts3 > > … Read more