Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkerFaceColor not parsed correctly #1082

Open
steefan85 opened this issue Jul 29, 2020 · 3 comments · May be fixed by #1083
Open

MarkerFaceColor not parsed correctly #1082

steefan85 opened this issue Jul 29, 2020 · 3 comments · May be fixed by #1083

Comments

@steefan85
Copy link

steefan85 commented Jul 29, 2020

Hello community!

This Matlab-code (R2020a):

x = linspace(1,2*pi,20);
y = sin(x);

h = plot(x, y)

set(h, 'Color', 'k'); 
set(h,'Marker','s');
set(h,'MarkerFaceColor','w');

matlab2tikz('plot.tex','width', '\figurewidth');

leads to the following tikz graphics:
plot

but the markers should be filled white:
plot_matlab

In the tikz-code, you can see the problem:

\begin{tikzpicture}

\begin{axis}[%
width=0.951\figurewidth,
height=0.75\figurewidth,
at={(0\figurewidth,0\figurewidth)},
scale only axis,
xmin=1,
xmax=7,
ymin=-1,
ymax=1,
axis background/.style={fill=white},
legend style={legend cell align=left, align=left, draw=white!15!black}
]
\addplot [color=black, mark=square*, mark options={solid, fill=white, black}]
  table[row sep=crcr]{%
1	0.841470984807897\\
1.2780623845884	0.957458518463391\\
1.5561247691768	0.999892374629122\\
1.8341871537652	0.965512708506724\\
2.1122495383536	0.856960627596325\\
2.390311922942	0.682575297090105\\
2.6683743075304	0.455753310272944\\
2.94643669211879	0.193919538242877\\
3.22449907670719	-0.0828114798817484\\
3.50256146129559	-0.35318077186763\\
3.78062384588399	-0.596418084672597\\
4.05868623047239	-0.793837492468504\\
4.33674861506079	-0.930272882916045\\
4.61481099964919	-0.995243045065974\\
4.89287338423759	-0.983756854748334\\
5.17093576882599	-0.896696701666613\\
5.44899815341439	-0.740750702641015\\
5.72706053800279	-0.527898908500852\\
6.00512292259119	-0.274492975132405\\
6.28318530717959	-2.44929359829471e-16\\
};
\addlegendentry{data1}

\end{axis}
\end{tikzpicture}%

matlab2tikz parsed two colors to the fill option:
mark options={solid, fill=white, black}

If I correct the tikz-file to
mark options={solid, fill=white}

everything is fine.

In Matlab
get(h, 'MarkerFaceColor');

returns just one color:
[1,1,1]

Why does matlab2tikz parse two colors to the mark options? Is there a solution for this?

Thanks,
regards
Stefan

@miscco
Copy link
Contributor

miscco commented Jul 29, 2020

I haven't looked at the code but my assumption would be that the second color that you see is meant to be the color of the surrounding.

You might want to have a look here and fix the wrong fill

Unfortunately I do not have access to MATLAB anymore so I cannot really help

@steefan85
Copy link
Author

Thank you, that helped.

I changed:

% get the marker color right
        markerInfo = getMarkerInfo(m2t, h, markOptions);

        [m2t, markerInfo.options] = setColor(m2t, h, markerInfo.options, 'fill', markerInfo.FaceColor);

        if ~strcmpi(markerInfo.EdgeColor,'auto')
            [m2t, markerInfo.options] = setColor(m2t, h, markerInfo.options, '', markerInfo.EdgeColor);
        else
            if isprop(h,'EdgeColor')
                color = get(h, 'EdgeColor');
            else
                color = get(h, 'Color');
            end
            [m2t, markerInfo.options] = setColor(m2t, h, markerInfo.options, '', color);
        end

to

% get the marker color right
        markerInfo = getMarkerInfo(m2t, h, markOptions);

        [m2t, markerInfo.options] = setColor(m2t, h, markerInfo.options, 'fill', markerInfo.FaceColor);

        if ~strcmpi(markerInfo.EdgeColor,'auto')
            [m2t, markerInfo.options] = setColor(m2t, h, markerInfo.options, 'draw', markerInfo.EdgeColor); %changed '' to 'draw'
        else
            if isprop(h,'EdgeColor')
                color = get(h, 'EdgeColor');
            else
                color = get(h, 'Color');
            end
            [m2t, markerInfo.options] = setColor(m2t, h, markerInfo.options, 'draw', color); %changed '' to 'draw'
        end

@miscco
Copy link
Contributor

miscco commented Jul 29, 2020

Wait wait wait:

Would you care to fix this issue for others too? If so a pull request would be highly appreciated

@miscco miscco reopened this Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants