LaTeX forum ⇒ Graphics, Figures & TablesAlter Frequency of Plot Markers Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
sderijck
Posts: 2
Joined: Wed Feb 20, 2013 2:54 pm

Alter Frequency of Plot Markers

Postby sderijck » Wed Feb 20, 2013 3:05 pm

Hello,

I try to change the frequency of plot markers. To be more precisely: I create a figure in which six graphs are depicted. To distinguish the graphs from each other, I use solid and dashed lines with a different gray scale, but I also want to add markers. However, these markers should not appear for each data entry (thus sample), but let's say every 50 samples one marker. This is to avoid a chaotic figure, because there are around 600 data entries, for each time step one. I have added the code below.
  1. \documentclass[conference]{IEEEtran}
  2. \usepackage{pgfplots}
  3. \usepackage{tikz}
  4. \usetikzlibrary{plotmarks}
  5.  
  6. \begin{document}
  7. \begin{figure*}[!t]
  8. \centering
  9. \begin{tikzpicture}
  10. \begin{axis}[
  11. xmin=0,
  12. xmax=600,
  13. width=18cm,
  14. height=8cm,
  15. legend pos=north east,
  16. xlabel = Time {[sec]},
  17. ylabel = Power {[p.u.]}
  18. ]
  19. \addplot[solid,color=black!30!white] file {./data/M2T1opt.dat};
  20. \addlegendentry{\footnotesize Turbine 1};
  21. \addplot[dashed,color=black!30!white] file {./data/M2T1optO2.dat};
  22. \addlegendentry{\footnotesize Turbine 1};
  23. \addplot[solid,color=black!70!white] file {./data/M2T2opt.dat};
  24. \addlegendentry{\footnotesize Turbine 2};
  25. \addplot[dashed,color=black!70!white] file {./data/M2T2optO2.dat};
  26. \addlegendentry{\footnotesize Turbine 2};
  27. \addplot[solid,mark=none,color=black] file {./data/M2Topt.dat};
  28. \addlegendentry{\footnotesize 2 turbines};
  29. \addplot[dashed,mark=none,color=black] file {./data/M2ToptO2.dat};
  30. \addlegendentry{\footnotesize 2 turbines};
  31. \end{axis}
  32. \end{tikzpicture}
  33. \end{figure*}
  34. \end{document}

Does anyone have a good suggestion for this problem?

Many thanks for your help

Simon
Attachments
data.zip
The needed data sets.
(27.61 KiB) Downloaded 164 times
Last edited by sderijck on Wed Feb 20, 2013 9:56 pm, edited 3 times in total.

Tags:

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Postby svend_tveskaeg » Wed Feb 20, 2013 3:10 pm

Welcome to the board!

  1. Please provide a Infominimal working example.
  2. You can tag the code as such by clicking the [Code] button just above the window where the type the text for the post.
  3. I can see that you are working with some external data files. You should attached these to your post.

P.S. When this is said, I don't know TikZ so I can't you with the specific problem; sorry. I am sure others can help, though.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Wed Feb 20, 2013 7:13 pm

sderijck wrote:[…] To distinguish the graphs from each other, I use solid lines with a different gray scale, but I also want to add markers. However, these markers should not appear for each data entry (thus sample), but let's say every 50 samples one marker. […]

In Section 4.6.1 the pgfplots manual introduces the key mark repeat as option for the \addplot command. To make this visible in your plots, just add some settings for the markers. The below example does that for the first plot. The output is attached.
  1. \documentclass[11pt]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{pgfplots}
  4. \usetikzlibrary{plotmarks}
  5.  
  6. \pgfplotsset{
  7. compat=newest,
  8. xlabel near ticks,
  9. ylabel near ticks
  10. }
  11.  
  12. \begin{document}
  13. \begin{tikzpicture}
  14. \begin{axis}[
  15. width=18cm,
  16. height=8cm,
  17. xmin=0,
  18. xmax=600,
  19. xlabel={Time [sec]},
  20. ylabel={Power [p.u.]},
  21. legend pos=north east,
  22. legend style={font=\footnotesize}
  23. ]
  24. \addplot[solid,mark=*,mark repeat=10,color=black!30!white] file {./data/M2T1opt.dat};
  25. \addlegendentry{Turbine 1};
  26. \addplot[dashed,color=black!30!white] file {./data/M2T1optO2.dat};
  27. \addlegendentry{Turbine 1};
  28. \addplot[solid,color=black!70!white] file {./data/M2T2opt.dat};
  29. \addlegendentry{Turbine 2};
  30. \addplot[dashed,color=black!70!white] file {./data/M2T2optO2.dat};
  31. \addlegendentry{Turbine 2};
  32. \addplot[solid,mark=none,color=black] file {./data/M2Topt.dat};
  33. \addlegendentry{2 turbines};
  34. \addplot[dashed,mark=none,color=black] file {./data/M2ToptO2.dat};
  35. \addlegendentry{2 turbines};
  36. \end{axis}
  37. \end{tikzpicture}
  38. \end{document}

This way the markers will also be shown in the legend. And perhaps you want to use some other line styles listed in Section 4.6.2 of the package manual.


Best regards and welcome to the board
Thorsten
Attachments
rtmp.png
rtmp.png (27.09 KiB) Viewed 5980 times
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

sderijck
Posts: 2
Joined: Wed Feb 20, 2013 2:54 pm

Postby sderijck » Wed Feb 20, 2013 10:11 pm

Thank you for the quick help!

I should have checked the manual updates. In the old manual it is mentioned somewhere hidden.

Kind regards
Simon


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 6 guests