I need some help to plot a small figure for my thesis. I know that the question is towards Matlab, but I export the figure as a tikzpicture and genuinely think that you guys deliver the better solution.

I think the question is quite simple but however I have not found a solution yet... What I want to do is to plot my figure with its x-axis that ranges from 0 to 5 in steps of 0.5. Now I want to add 2 specific values (say 1.1 and 3.387) to the x-axis and label them as f_1 and f_2. I tried using xtick but it did not work.

enter image description here

The tikz code as exported from Matlab:

% This file was created by matlab2tikz.
%The latest updates can be retrieved from
%  http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.

scale only axis,
xlabel style={font=\color{white!15!black}},
xlabel={Frequency [Hz]},
ylabel style={font=\color{white!15!black}},
ylabel={$\text{Acceleration [m/s}^\text{2}\text{]}$},
axis background/.style={fill=white},
title style={font=\bfseries},
title={Dynamic Operating Space},
legend style={legend cell align=left, align=left, draw=white!15!black}
\addplot [color=red, dashed]
  table[row sep=crcr]{%
1.15749049521378    0\\
1.15749049521378    40\\

\addplot [color=red, dashed]
  table[row sep=crcr]{%
3.48151438013521    0\\
3.48151438013521    40\\

\addplot [color=black, line width=2.0pt]
  table[row sep=crcr]{%
0   0\\
1.15749049521378    11.6363636363636\\

\addplot [color=black, line width=2.0pt]
  table[row sep=crcr]{%
1.15749049521378    11.6363636363636\\
3.48151438013521    35\\

\addplot [color=black, line width=2.0pt]
  table[row sep=crcr]{%
3.48151438013521    35\\
5   35\\

\node[right, align=left, rotate=45]
at (axis cs:0.3,5.5) {$\text{x}_{\text{max}}\text{ = 0.22m}$};
\node[right, align=left, rotate=45]
at (axis cs:2,22.5) {$\text{v}_{\text{max}}\text{ = 1.6m/s}$};
\node[right, align=left]
at (axis cs:4,36.5) {$\text{a}_{\text{max}}\text{ = 35m/s}^\text{2}$};

If the x-axis would now display the full range in addition to above f_1 and f_2 I'd be very happy.

Any clue ? Additionally, is there any way to grey out the area under the curves ?

Thank you !

  • Could you post the tikz code that is generated for this figure, as part of a small compilable document? Without that it is not really possible to tell you how you can get the output that you want. – Marijn Dec 30 '19 at 16:13
  • @Marijn just added my code :) – aladin Dec 30 '19 at 16:24
  • 1
    You can achieve this with extra x ticks={1.1,3.387}, extra x tick labels={$f_1$,$f_2$}. Do you want to keep the current ticks? – Schrödinger's cat Dec 30 '19 at 18:26
  • @Schrödinger'scat Thank you ! Got it ;) – aladin Dec 30 '19 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.