Closed
Description
Bug report
- The
markevery
option forplot
,semilogx
,semilogy
, andloglog
plotting methods has a weird difference of behavior betweenplot / semilogy
andsemilogx / loglog
, when usingmarkevery = (float, float)
.
Code for reproduction
import numpy as np
import matplotlib.pyplot as plt
# Generate some data
X = np.linspace(-10, 10, 1000)
Y = np.sin(X)**2
# Specify markers
markers = ['o', 'v', '^', '<', '>']
def markevery(i):
# I tried a *lot* of values here, none were working for the 4 plots
return (i / 50., 0.1)
plt.figure()
# First plot in normal plot
plt.subplot(221)
for i in range(10):
plt.plot(X, Y + i / 10., marker=markers[i % len(markers)], markevery=markevery(i), label=str(i))
plt.legend()
plt.title("plt.plot(): markers are here!")
# Then plot in semilogx
plt.subplot(222)
for i in range(10):
plt.semilogx(X, Y + i / 10., marker=markers[i % len(markers)], markevery=markevery(i), label=str(i))
plt.legend()
plt.title("plt.semilogx(): markers are NOT here!")
# And then semilogy
plt.subplot(223)
for i in range(10):
plt.semilogy(X, Y + i / 10., marker=markers[i % len(markers)], markevery=markevery(i), label=str(i))
plt.legend()
plt.title("plt.semilogy(): markers are here!")
# Finally plot in loglog
plt.subplot(224)
for i in range(10):
plt.loglog(X, Y + i / 10., marker=markers[i % len(markers)], markevery=markevery(i), label=str(i))
plt.legend()
plt.title("plt.loglog(): markers are NOT here!")
plt.suptitle("Weird behavior of markevery between plt.plot, plt.semilogx, plt.semilogy, plt.loglog")
plt.show()
Expected outcome
- One would expect the markers to be located in a similar fashion for each of the four plots method,
plot
,semilogx
,semilogy
, andloglog
. The two plots on the left have markers correctly located (well spacen, with a different starting point for the different curves), and the two plots on the right do not show markers. - Note that I tried a lot of different values for the
markevery
parameters (heremarkevery = (i / 50., 0.1)
for the various curves, with changingi
to change the starting point of the markers), and always encounter this inconsistency between left and right.
Matplotlib version
- Matplotlib version 2.0.0 (
2.0.0+3337.gc15694b
), with Python 3.5, on Ubuntu 16.10 - Python installed with apt, latest version of Matplotlib installed with
pip --upgrade
.
Maybe I don't understand the semantic behind using markevery = (float, float)
, but as far as I can tell, this behavior is weird.
Thanks in advance!