0
votes

I have made the following plot for an engine's piston speed. Notice on the x axis goes from about 0 to 360 degrees with a spacing of 50. How can I change this to a spacing of 90? Thanks for any help anyone can provide.

chart

My Plotting code is shown as follows:

plt.figure()
x_axis = theta_range_deg
plt.subplot(1, 3, 1)
plt.plot(x_axis, position_list)
plt.xlabel("Angle (degrees)")
plt.ylabel("Position (in)")
plt.title("Position vs Angle")
plt.grid(color='grey', linestyle='-', linewidth=.5)

plt.subplot(1, 3, 2)
plt.plot(x_axis, piston_speed_list)
plt.plot(x_axis,mean_speed_list)
plt.plot(90, 0,'.', color = 'black')
plt.plot(270, 0,'*', color = 'black')
plt.xlabel("Angle (degrees)")
plt.ylabel("Piston Velocity (mph)")
plt.title("Piston Speed vs Angle")
plt.grid(color='grey', linestyle='-', linewidth=.5)
plt.gca().legend(('True Speed','Mean Piston Speed','Top Dead Center','Bottom Dead Center'))

plt.subplot(1, 3, 3)
plt.plot(x_axis, acceleration_list)
plt.xlabel("Angle (degrees)")
plt.ylabel("Piston Acceleration (g)")
plt.title("Piston Net Force vs Angle")
plt.grid(color='grey', linestyle='-', linewidth=.5)
plt.show()
1
What plotting library are you using? You need to edit to add the tag, e.g. matplotlib, plotly. It might also help to provide a minimal reproducible example. BTW, welcome to Stack Overflow! Check out the tour, and How to Ask if you want tips. - wjandrea

1 Answers

0
votes

You can utilize plt.xticks(), passing a list of tick locations on a half-closed interval [start, end) and step size, for example:

import matplotlib.pyplot as plt

import numpy as np

plt.xticks(np.arange(0, 450, step=90))
plt.show()

xticks