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

How to set xticklabels but use math environment not text font #1100

Open
Silas2012 opened this issue Aug 29, 2021 · 1 comment
Open

How to set xticklabels but use math environment not text font #1100

Silas2012 opened this issue Aug 29, 2021 · 1 comment

Comments

@Silas2012
Copy link

Hello,
I am generating a tikzpicture with following Code:

X = 1:1:10;
Y = sin(X);
plot(X,Y);
xticks(X);
xticklabels({'$1$','','$2$','','$3$','','$4$','','$5$',''});
cleanfigure;
matlab2tikz('testfig.tex', 'showInfo', false);

the generated lines for the xticklabels are: (Full Code attached)

xtick={1,2,3,4,5,6,7,8,9,10},
xticklabels={{\$1\$},{},{\$2\$},{},{\$3\$},{},{\$4\$},{},{\$5\$},{}},

Is there a way to tell matlab2tikz, not to interpret the text and exchange $ with \$ but just take it as is?
The compiled Picture looks like this:
Compiled
For the Y-axis, math font is used, but as labels are often text, for the X-axis the normal text font style is used, why I tried with $...$ environment.
So my original Problem is simply, that I dont want every ticklabel to be printed, but have it both in math font style.
I appreciate any help or workaround for this problem. Probably I am missing something as these are my first tries with this package.
Simon

testfig.txt

@egeerardyn
Copy link
Member

The aspects that have an impact on how those get displayed:

  1. whether or not override some properties (e.g. as using xticks/xticklabels) -> the general philosophy in matlab2tikz is that if we notice you let MATLAB do its thing, we assume you do not care about how it looks and that we can let pgfplots do its own thing, which might not match MATLAB behavior), that is probably part why you see that behavior
  2. how those $ get interpreted, is set in part by which text interpreter you set for the particular object in MATLAB. You may want to try changing that (if memory serves me well, setting it to latex for the tick labels may do the trick)
  3. in matlab2tikz we have tons of arguments that can change the behavior of the conversion, see help matlab2tikz or the source code. For your case in specific, have a look at interpretTickLabelsAsTex, parseStrings, parseStringsAsMath.

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

No branches or pull requests

2 participants