1

i want to change the direction of the colormap of a scatterplot. The "best" points in my plot are in the lower right, the "worst" in the upper left. So it would be nice, if the points in the lower right would be blue, in the upper left red. Right now, it fades just from the bottom to the top. I've read the manueal and was just able to change the different colors, but not the direction of the fading.

Best Regards, Tobias

      \documentclass{article}
  \usepackage{pgfplots}

  \begin{filecontents*}{dataset.csv}
  ID;X;Y
  1;4,255833333333333;3,3208333333333333
  2;3,42;3,3533333333333335
  3;1,986388888888889;1,101388888888889
  4;5,885277777777778;1,3702777777777777
  5;0,3502777777777778;0,3502777777777778
  6;4,671666666666667;4,671666666666667
  7;5,0377777777777775;0,11666666666666667
  8;6,9752777777777775;5,187777777777778
  9;16,851666666666667;1,3669444444444445
  10;0,050555555555555555;0,050555555555555555
  11;26,075555555555557;3,9541666666666666
  12;27,698888888888888;0,15
  13;3,1058333333333334;2,2866666666666666
  14;29,035;4,486944444444444
  15;7,001666666666667;4,0008333333333335
  16;9,088055555555556;2,3855555555555554
  17;50,58638888888889;1,7855555555555556
  18;2,218888888888889;1,6344444444444444
  19;47,8325;7,5905555555555555
  20;8,5925;2,5347222222222223
  21;6,671666666666667;2,6683333333333334
  22;75,84138888888889;4,170833333333333
  23;75,45682;1,5418
  24;70,5454635;0,545654
  25;80;0
  26;0;7.545666774
  \end{filecontents*}

  \begin{document}
    \begin{tikzpicture}
      \begin{axis}
        \addplot[
        scatter,
        only marks,
        /pgf/number format/read comma as period] table [x=X, y=Y, col sep=semicolon] {dataset.csv};
      \end{axis}
    \end{tikzpicture}
  \end{document}
  • What is your question exactly? And why did you stop writing in the middle of your last sentence? – Runar May 31 '16 at 8:46
  • At the moment, points just above the x axis are blue and turn to red the higher they get. I want the the points with high x-value and low y-value to be blue, and the values with low x-value and high y-value to be red. – civilatio May 31 '16 at 9:25
1

I found the solution within this post: How to plot a third variable (z) on pgfplot as a color gradient

I had to introduce a third column to my dataset which defines the color gradient. This is just the quotient of the two axes.

The code looks now like this:

\begin{tikzpicture}
\begin{axis}[
  width=10.5cm,
  height=8  cm,
  xlabel=Standing Time h,
  ylabel=Charging Time h,
  ]
  \addplot[
  scatter,
  only marks,
  /pgf/number format/read comma as period,
  point meta=explicit,
  point meta min={0}, point meta max={1}] table [x=X, y=Y, meta=FACTOR, col sep=semicolon] {dataset.csv};
\end{axis}
\end{tikzpicture}
  • If this solved your problem could you accept your answer, please. This will prevent the question to pop up again later in the list as unanswered question again. – Stefan Pinnow Jun 4 '16 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.