Graphics, Figures & TablesAlter Frequency of Plot Markers

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

Alter Frequency of Plot Markers

Post by sderijck »

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.

Code: Select all

\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 374 times
Last edited by sderijck on Wed Feb 20, 2013 9:56 pm, edited 3 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

Alter Frequency of Plot Markers

Post by svend_tveskaeg »

Welcome to the board!
  1. Please provide a Infominimal working example.
  2. You can tag the code as such by clicking the

    Code: Select all

     button just above the window where the type the text for the post.
    [*]I can see that you are working with some external data files. You should attached these to your post.[/list]
    
    P.S. When this is said, I don't know Ti[i]k[/i]Z 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: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Alter Frequency of Plot Markers

Post by localghost »

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.

Code: Select all

\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
rtmp.png (27.09 KiB) Viewed 9602 times
sderijck
Posts: 2
Joined: Wed Feb 20, 2013 2:54 pm

Re: Alter Frequency of Plot Markers

Post by sderijck »

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
Post Reply