Open jgmakin opened 4 years ago
Can confirm the issue!
Does anyone have a workaround for this?
Possibly related due to scatter
flag inconsistencies: #480 #479
Easiest workaround is to replace scatter by plot. This won't offer all functionality of scatter, but for the MWE it is sufficient:
import matplotlib.pyplot as plt
from tikzplotlib import get_tikz_code
import numpy as np
fig, ax = plt.subplots()
max_marker_size = 300
ax.plot(
[1, 2, 3], [5, 7, 1],
linestyle='None', marker='o', markersize=np.sqrt(max_marker_size),
markeredgecolor='black', markerfacecolor='none', linewidth=3.0
)
get_tikz_code()
gives the desired result. Note that the markersize setting of plot is not the same as the size setting of scatter, so you need to take the root of the scatter size to get the intended size.
MWE: This bit of code plots open circles of a fixed but non-default size:
but the
tex
code it produces,does not use the size information to adjust the marks.
This can be remedied simply by pre-pending
scatter
to the list of\addplot
options (see Sec. 4.5.12 of the pgfplots manual)--except thatpgfplots
will then try to impose a color scheme as well. That can be fixed by changing.append style
to.style
inscatter/@pre marker code/.append style={/tikz/mark size=\perpointmarksize}
, and adding an empty post-marker:scatter/@post marker code/.style={}
. Hence, the workingtex
code would be:I can try to make the appropriate changes to
tikzplotlib
myself (presumably somewhere around here), but I don't think I have a good enough handle on all the cases this bit of code is supposed to cover.(I note in passing that
linewidths=3.0
also appears to have no effect; perhaps I should open this as a separate issue.)