Plot two graphs in same plot in R
lines() or points() will add to the existing graph, but will not create a new window. So you’d need to do plot(x,y1,type=”l”,col=”red”) lines(x,y2,col=”green”)
lines() or points() will add to the existing graph, but will not create a new window. So you’d need to do plot(x,y1,type=”l”,col=”red”) lines(x,y2,col=”green”)
There are two closely-related questions, and an answer for each. 1. An image will be generated in future in my script, how do I save it to disk? To save a plot, you need to do the following: Open a device, using png(), bmp(), pdf() or similar Plot your model Close the device using dev.off() … Read more
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
You get it directly from the axes’ patches: for p in ax.patches: ax.annotate(str(p.get_height()), (p.get_x() * 1.005, p.get_height() * 1.005)) You’ll want to tweak the string formatting and the offsets to get things centered, maybe use the width from p.get_width(), but that should get you started. It may not work with stacked bar plots unless you … Read more
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
figure tells you the call signature: from matplotlib.pyplot import figure figure(figsize=(8, 6), dpi=80) figure(figsize=(1,1)) would create an inch-by-inch image, which would be 80-by-80 pixels unless you also give a different dpi argument.
figure tells you the call signature: from matplotlib.pyplot import figure figure(figsize=(8, 6), dpi=80) figure(figsize=(1,1)) would create an inch-by-inch image, which would be 80-by-80 pixels unless you also give a different dpi argument.
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
surf is a function which displays a quad-mesh, from your output I can only tell that you did not input the data in the right order or shape, it seems to randomly connect the wrong points. In the simplest case (a regular quad-mesh) means that each column of X contains the same value and each … Read more
You try to assign a value to u1[…] without even having created u1. You should init u1 before trying to init its elements.