LaTeX forum ⇒ Graphics, Figures & TablesColor of my plot is not as I defined it

Information and discussion about graphics, figures & tables in LaTeX documents.
Posts: 1
Joined: Mon May 18, 2020 5:47 pm

Color of my plot is not as I defined it

Postby Lorothar » Mon May 18, 2020 5:57 pm

Hi there,

this is probably an easy error by myself, but I am not an expert in LaTeX. I try to plot some simple Data points from a csv file and add a regression function for three different Data sets, which works fine with tikz and pgfplots. But the color I define for the plots does not show correctly. I want the first one blue, the second one red and the third one orange. The regression lines are fine, but on my Data points the marks only have the specified color on the edges and are not filled with it.

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \begin{figure}
  2. \begin{tikzpicture}
  3. \begin{axis} [xmax=2, xmin=-1.5, samples=50]
  4. \addplot+ [mark=square*, color=blue, only marks] table [x=Zyklische
  5. Arbeitslosigkeit, y=Kerninflation, col sep=comma] {data/Infl.csv};
  6. \plot [blue] plot[samples=100, smooth]
  7. expression{-1.7073409589*x+8.0008968844};
  8. \addplot+ [mark=square*, color=red, only marks] table [x=Zyklische Arbeitslosigkeit,
  9. y=Kerninflation, col sep=comma] {data/Infl2.csv};
  10. \plot [red] plot[samples=100, smooth]
  11. expression{-0.8226914063*x+5.1310272065};
  12. \addplot+ [mark=square*, color=orange, only marks] table [x=Zyklische
  13. Arbeitslosigkeit, y=Kerninflation, col sep=comma] {data/Infl3.csv};
  14. \plot [orange] plot[samples=100, smooth]
  15. expression{-0.1404751478*x+1.8775287948};
  16. \end{axis}
  17. \end{tikzpicture}
  18. \end{figure}

This is my code for the figure.


And this is what I am getting from it.

Sorry if I am doing anything wrong with this post, but I just need some quick help.

Kind regards
Last edited by Lorothar on Mon May 18, 2020 7:25 pm, edited 2 times in total.

Posts: 68
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Mon May 18, 2020 6:53 pm

We don't have the data that your example reads from the csv files.

Please complete your example to a minimal working example and use the appropriate BBCode ([code] instead of [quote]), the highlighting of which makes reading your source code more pleasant.

Posts: 68
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Tue May 19, 2020 5:30 am

The Section 4.7 "Markers, Linestyles, (Background) Colors and Colormaps" of the documentation of the pgfplots package should contain what you need.

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 1 guest