I'm using Python to plot several straight lines on the same plot.
I have a great variability in values magnitude over x values (called with variable q
in my code), so I want to put them at the same distance on the x-axis, in order to have a clear vision on the first part of the graph.
Here my code:
def c(m,x):
'''
Linear cost function, describing costs for each weight range
:param m: the slope, modelling rates
:param x: the abscissa, modelling quantity ordered
:return: the cost value for each quantity
'''
return m * x
for i in range(0,9):
w = np.arange(0., q[9], 0.01)
plt.plot(w,c(r[i],w),'b--',linewidth=0.3)
plt.plot( [q[i],breakpoints[i]] , [c(r[i], q[i]), c(r[i], breakpoints[i])], 'r')
plt.plot(q[i + 1], c(r[i], breakpoints[i]), 'r.')
plt.show()
For the sake of simplicity, here there is all data involved in my code snippet:
As you can see, this is the classical quantity discount study. So, if I simply plot these values, I can't distinguish what is happening at the first straight lines, since little space is reserved to the first q values, see below:
Now I show you the zoomed graph on first q values:
The solution I have thought about is to plot all q[]
values at same distance: see the next picture.
So all I want to achieve is simply to have all q[] values at the same distance on x-axis, independently on their value. How can I do this?