## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Alter 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

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.
\documentclass[conference]{IEEEtran}\usepackage{pgfplots}\usepackage{tikz}\usetikzlibrary{plotmarks} \begin{document}   \begin{figure*}[!t]     \centering     \begin{tikzpicture}       \begin{axis}[         xmin=0,         xmax=600,         width=18cm,         height=8cm,         legend pos=north east,         xlabel = Time {[sec]},         ylabel = Power {[p.u.]}       ]         \addplot[solid,color=black!30!white] file {./data/M2T1opt.dat};         \addlegendentry{\footnotesize Turbine 1};         \addplot[dashed,color=black!30!white] file {./data/M2T1optO2.dat};         \addlegendentry{\footnotesize Turbine 1};         \addplot[solid,color=black!70!white] file {./data/M2T2opt.dat};         \addlegendentry{\footnotesize Turbine 2};         \addplot[dashed,color=black!70!white] file {./data/M2T2optO2.dat};         \addlegendentry{\footnotesize Turbine 2};         \addplot[solid,mark=none,color=black] file {./data/M2Topt.dat};         \addlegendentry{\footnotesize 2 turbines};         \addplot[dashed,mark=none,color=black] file {./data/M2ToptO2.dat};         \addlegendentry{\footnotesize 2 turbines};       \end{axis}     \end{tikzpicture}   \end{figure*}\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 174 times
Last edited by sderijck on Wed Feb 20, 2013 9:56 pm, edited 3 times in total.

Tags:

svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Welcome to the board!

1. Please provide a minimal 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)

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 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.
\documentclass[11pt]{article}\usepackage[T1]{fontenc}\usepackage{pgfplots}\usetikzlibrary{plotmarks} \pgfplotsset{   compat=newest,   xlabel near ticks,   ylabel near ticks} \begin{document}   \begin{tikzpicture}     \begin{axis}[       width=18cm,       height=8cm,       xmin=0,       xmax=600,       xlabel={Time [sec]},       ylabel={Power [p.u.]},       legend pos=north east,       legend style={font=\footnotesize}     ]       \addplot[solid,mark=*,mark repeat=10,color=black!30!white] file {./data/M2T1opt.dat};       \addlegendentry{Turbine 1};       \addplot[dashed,color=black!30!white] file {./data/M2T1optO2.dat};       \addlegendentry{Turbine 1};       \addplot[solid,color=black!70!white] file {./data/M2T2opt.dat};       \addlegendentry{Turbine 2};       \addplot[dashed,color=black!70!white] file {./data/M2T2optO2.dat};       \addlegendentry{Turbine 2};       \addplot[solid,mark=none,color=black] file {./data/M2Topt.dat};       \addlegendentry{2 turbines};       \addplot[dashed,mark=none,color=black] file {./data/M2ToptO2.dat};       \addlegendentry{2 turbines};     \end{axis}   \end{tikzpicture}\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 (27.09 KiB) Viewed 6317 times
LaTeX Community Moderator

¹ 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
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 4 guests