I have data below and I want to plot the graph by repeating the x-axis.
| 30 | | 0.650297475 | | 40 | | 0.657665519 | | 50 | | 0.669169 975 | | 60 | | 0.69 5916956 | | 50 | | 0.6802548 94. | 40 | | 0.663912144 | | 30 | | 0.653692469 | | 20 | | 0.644423894 | | 10 | | 0.637784575 | | 0 | | 0.626213656 | | 10 | | 0.63776 963 9. | 20 | | 0.643006988 | | 30 | | 0.646742206 | | 50 | | 0.668539731 | | 60 | | 0.6 949 59 9 31. | 50 | | 0.679511669 | | 40 | | 0.6633013 | | 30 | | 0.653026313 | | 20 | | 0.644 97036 9. | 10 | | 0.63772 925. | 0 | | 0.6264 9 4163 | | 20 | | 0.643006456 | | 30 | | 0.646692806 | | 40 | | 0.656562469 | | 50 | | 0.668683988 | | 60 | | 0.69528 9 806 | | 50 | | 0.680420325 | | 40 | | 0.663145675 | | 30 | | 0.654077156 | I am trying to plot it by using myplotlib x = class (lan (x_axis)) fig = plt.figure () Ax = plt.gca () Ax.ticklabel_format (useOffset = False) ax.set_xticks (x_axis, minor = true) CH1 = ax.plot (x, y_axis) ax.legend ([parameter]) #, bbox_to_anchor = (1.05, 1), loc = 2, bordersasseds = 0 fig. ("Plotfile_get_vendor_version_here" + ".png") plt.close (fig)
but the x-axis value ends at 30. I understand that due to this range function can I fix it in some way. I would be really useful for support.
Regards, Wind
You need ax.set_xticklabels (to)
to:
NMP imports as imports Matplotlib.pyplot plt # as the data: x_axis = np.array ([30., 40., 50., 60., 50., 40, 30., 20., 10., 0., 10., 20 ., 30., 50., 60., 50., 40., 30., 20., 10., 0., 20., 30., 40., 50., 60., 50., 40., 30.] y_axis = np.array ([0.65029748, 0.65766552, 0.66916997, 0.69591696, 0.65369247, 0.64442389, 0.63778457, 0.62621366, 0.63776906, 0.6430069 9, 0.64674221, 0.66853973, 0.69495993, 0.67951167, 0.6633013, 0.65752631, 0.64497037, 0.6 3772925, 0.6264 9416, 0.64300646, 0.64669281, 0.65656247, 0.66868399, 0.69528981, 0.68042033, 0.66314567, 0.65407716] x = range (LAN (x_axis)) figs, X = Plt.subplots (1, 1) ax.set_xticks (x) # Set Tick Status # Labels are created as integers: ax.set_xticklabels (["{: d}". Format (int (v))] in x_axis to v) Ax.plot (x, y_axis) fig.canvas.draw () # actually figure Enter draw plt.show () # GUI loop N-interactive interpreters) < / Code>
Alternatively you can try to do something like
No comments:
Post a Comment