Zaript
Zaript

Reputation: 31

Line markers density

I plot a couple of lines in log scale with a huge amount of points. I plot them in black using different line styles/markers. I use "markevery" property to decrease amount of markers. X-values change at even intervals.

The issue I have is that markers distributed unevenly - less of them near 0, and more near the right end of each line. Is there are any way to get around this issue without nitpicking x-values, so that they will be "evenly" distributed on log-scale?

Upvotes: 3

Views: 793

Answers (1)

imsc
imsc

Reputation: 7840

You can give the index of points you want to plot. In logscale these points should be non-uniformly distributed. You can try logspace to achieve it.

import pylab as plt
import numpy as np

x=np.arange(1,1e5)

# Normal plot
#plt.plot(x,x,'o-')

# Log plot
idx=np.logspace(0,np.log10(len(x)),10).astype('int')-1
plt.plot(x[idx],x[idx],'o-')
plt.xscale('log')
plt.yscale('log')
plt.show()

generates: enter image description here

Upvotes: 4

Related Questions