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

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

Color of my plot is not as I defined it

Post by Lorothar »

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

\begin{figure}
		\begin{tikzpicture}
			\begin{axis}		[xmax=2,	xmin=-1.5,	samples=50]
				\addplot+	[mark=square*,	color=blue,	only marks]	table	[x=Zyklische
				Arbeitslosigkeit,	y=Kerninflation,	col sep=comma]	{data/Infl.csv};
				\plot		[blue] plot[samples=100, smooth] 
				expression{-1.7073409589*x+8.0008968844};
				\addplot+	[mark=square*,	color=red,	only marks]	table	[x=Zyklische Arbeitslosigkeit,
				y=Kerninflation,	col sep=comma]	{data/Infl2.csv};
				\plot		[red] plot[samples=100, smooth] 
				expression{-0.8226914063*x+5.1310272065};
				\addplot+	[mark=square*,	color=orange,	only marks]	table	[x=Zyklische
				Arbeitslosigkeit,	y=Kerninflation,	col sep=comma]	{data/Infl3.csv};
				\plot		[orange] plot[samples=100, smooth] 
				expression{-0.1404751478*x+1.8775287948};
			\end{axis}
		\end{tikzpicture}
	\end{figure}
This is my code for the figure.

Image

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.

Recommended reading 2024:

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

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

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Color of my plot is not as I defined it

Post by Bartman »

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.
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Color of my plot is not as I defined it

Post by Bartman »

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