Changing Color in Coordinate Plot in Tikz












6














I want to change the color in alternates of red and blue. So far I only have:



 documentclass{article}
usepackage{tikz}

begin{document}
begin{center}
begin{tikzpicture}[scale=.8]
% Axes
draw [-latex] (-1,0) -- (12,0) node (xaxis) [right] {$x$};
draw [-latex] (0,-1) -- (0,6.5) node [above] {$y$};
% Origin
node at (0,0) [below left] {$0$};
% Points
coordinate (start) at (1,1.5);
coordinate (1) at (3,.5);
coordinate (2) at (5.5,4.5);
coordinate (3) at (7.5,2.75);
coordinate (end) at (9,6);
% Plot
draw [red,thick,-] (start) to[out=-30,in=180] (1) to[out=0,in=180]
(2) to[out=0,in=110] (3) to[out=45,in=225] (end);

% show the points

foreach n in {start,1,2,3,end} fill [black] (n)
circle (2pt) node [below] {};

end{tikzpicture}
end{center}
end{document}


This outputs:



enter image description here



Any advice how to make the color alternative between red and blue with one color between each point?










share|improve this question



























    6














    I want to change the color in alternates of red and blue. So far I only have:



     documentclass{article}
    usepackage{tikz}

    begin{document}
    begin{center}
    begin{tikzpicture}[scale=.8]
    % Axes
    draw [-latex] (-1,0) -- (12,0) node (xaxis) [right] {$x$};
    draw [-latex] (0,-1) -- (0,6.5) node [above] {$y$};
    % Origin
    node at (0,0) [below left] {$0$};
    % Points
    coordinate (start) at (1,1.5);
    coordinate (1) at (3,.5);
    coordinate (2) at (5.5,4.5);
    coordinate (3) at (7.5,2.75);
    coordinate (end) at (9,6);
    % Plot
    draw [red,thick,-] (start) to[out=-30,in=180] (1) to[out=0,in=180]
    (2) to[out=0,in=110] (3) to[out=45,in=225] (end);

    % show the points

    foreach n in {start,1,2,3,end} fill [black] (n)
    circle (2pt) node [below] {};

    end{tikzpicture}
    end{center}
    end{document}


    This outputs:



    enter image description here



    Any advice how to make the color alternative between red and blue with one color between each point?










    share|improve this question

























      6












      6








      6


      0





      I want to change the color in alternates of red and blue. So far I only have:



       documentclass{article}
      usepackage{tikz}

      begin{document}
      begin{center}
      begin{tikzpicture}[scale=.8]
      % Axes
      draw [-latex] (-1,0) -- (12,0) node (xaxis) [right] {$x$};
      draw [-latex] (0,-1) -- (0,6.5) node [above] {$y$};
      % Origin
      node at (0,0) [below left] {$0$};
      % Points
      coordinate (start) at (1,1.5);
      coordinate (1) at (3,.5);
      coordinate (2) at (5.5,4.5);
      coordinate (3) at (7.5,2.75);
      coordinate (end) at (9,6);
      % Plot
      draw [red,thick,-] (start) to[out=-30,in=180] (1) to[out=0,in=180]
      (2) to[out=0,in=110] (3) to[out=45,in=225] (end);

      % show the points

      foreach n in {start,1,2,3,end} fill [black] (n)
      circle (2pt) node [below] {};

      end{tikzpicture}
      end{center}
      end{document}


      This outputs:



      enter image description here



      Any advice how to make the color alternative between red and blue with one color between each point?










      share|improve this question













      I want to change the color in alternates of red and blue. So far I only have:



       documentclass{article}
      usepackage{tikz}

      begin{document}
      begin{center}
      begin{tikzpicture}[scale=.8]
      % Axes
      draw [-latex] (-1,0) -- (12,0) node (xaxis) [right] {$x$};
      draw [-latex] (0,-1) -- (0,6.5) node [above] {$y$};
      % Origin
      node at (0,0) [below left] {$0$};
      % Points
      coordinate (start) at (1,1.5);
      coordinate (1) at (3,.5);
      coordinate (2) at (5.5,4.5);
      coordinate (3) at (7.5,2.75);
      coordinate (end) at (9,6);
      % Plot
      draw [red,thick,-] (start) to[out=-30,in=180] (1) to[out=0,in=180]
      (2) to[out=0,in=110] (3) to[out=45,in=225] (end);

      % show the points

      foreach n in {start,1,2,3,end} fill [black] (n)
      circle (2pt) node [below] {};

      end{tikzpicture}
      end{center}
      end{document}


      This outputs:



      enter image description here



      Any advice how to make the color alternative between red and blue with one color between each point?







      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 27 '18 at 15:25









      MathScholar

      6508




      6508






















          1 Answer
          1






          active

          oldest

          votes


















          9














          Some improvements in the code.





          • standalone class to produce a single draw.

          • You can scope the lines to set the line width once.

          • You don't need to insert node in the bullets.


          • black is the default color, don't need to pass it to fill.


          enter image description here



          documentclass[tikz,margin=2mm]{standalone}

          begin{document}
          begin{tikzpicture}
          % Axes
          draw [-latex] (-1,0) -- (12,0) node (xaxis) [below] {$x$};
          draw [-latex] (0,-1) -- (0,6.5) node [left] {$y$};

          % Origin
          node at (0,0) [below left] {$0$};

          % Points
          coordinate (start) at (1,1.5);
          coordinate (1) at (3,.5);
          coordinate (2) at (5.5,4.5);
          coordinate (3) at (7.5,2.75);
          coordinate (end) at (9,6);

          % Plot
          begin{scope}[thick]
          draw [red] (start) to[out=-30,in=180] (1);
          draw [red!60!blue] (1) to[out=0,in=180] (2);
          draw [red!30!blue] (2) to[out=0,in=110] (3);
          draw [blue] (3) to[out=45,in=225] (end);
          end{scope}

          % show the points
          foreach n in {start,1,2,3,end}{%
          fill (n) circle (2pt);
          }
          end{tikzpicture}
          end{document}





          share|improve this answer























          • you broke it up in parts and then redefined the color. Thanks, for some reason I kept thinking that it wasn't possible.
            – MathScholar
            Dec 27 '18 at 15:44












          • @MathScholar, welcomed.
            – Sigur
            Dec 27 '18 at 15:49











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467553%2fchanging-color-in-coordinate-plot-in-tikz%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          9














          Some improvements in the code.





          • standalone class to produce a single draw.

          • You can scope the lines to set the line width once.

          • You don't need to insert node in the bullets.


          • black is the default color, don't need to pass it to fill.


          enter image description here



          documentclass[tikz,margin=2mm]{standalone}

          begin{document}
          begin{tikzpicture}
          % Axes
          draw [-latex] (-1,0) -- (12,0) node (xaxis) [below] {$x$};
          draw [-latex] (0,-1) -- (0,6.5) node [left] {$y$};

          % Origin
          node at (0,0) [below left] {$0$};

          % Points
          coordinate (start) at (1,1.5);
          coordinate (1) at (3,.5);
          coordinate (2) at (5.5,4.5);
          coordinate (3) at (7.5,2.75);
          coordinate (end) at (9,6);

          % Plot
          begin{scope}[thick]
          draw [red] (start) to[out=-30,in=180] (1);
          draw [red!60!blue] (1) to[out=0,in=180] (2);
          draw [red!30!blue] (2) to[out=0,in=110] (3);
          draw [blue] (3) to[out=45,in=225] (end);
          end{scope}

          % show the points
          foreach n in {start,1,2,3,end}{%
          fill (n) circle (2pt);
          }
          end{tikzpicture}
          end{document}





          share|improve this answer























          • you broke it up in parts and then redefined the color. Thanks, for some reason I kept thinking that it wasn't possible.
            – MathScholar
            Dec 27 '18 at 15:44












          • @MathScholar, welcomed.
            – Sigur
            Dec 27 '18 at 15:49
















          9














          Some improvements in the code.





          • standalone class to produce a single draw.

          • You can scope the lines to set the line width once.

          • You don't need to insert node in the bullets.


          • black is the default color, don't need to pass it to fill.


          enter image description here



          documentclass[tikz,margin=2mm]{standalone}

          begin{document}
          begin{tikzpicture}
          % Axes
          draw [-latex] (-1,0) -- (12,0) node (xaxis) [below] {$x$};
          draw [-latex] (0,-1) -- (0,6.5) node [left] {$y$};

          % Origin
          node at (0,0) [below left] {$0$};

          % Points
          coordinate (start) at (1,1.5);
          coordinate (1) at (3,.5);
          coordinate (2) at (5.5,4.5);
          coordinate (3) at (7.5,2.75);
          coordinate (end) at (9,6);

          % Plot
          begin{scope}[thick]
          draw [red] (start) to[out=-30,in=180] (1);
          draw [red!60!blue] (1) to[out=0,in=180] (2);
          draw [red!30!blue] (2) to[out=0,in=110] (3);
          draw [blue] (3) to[out=45,in=225] (end);
          end{scope}

          % show the points
          foreach n in {start,1,2,3,end}{%
          fill (n) circle (2pt);
          }
          end{tikzpicture}
          end{document}





          share|improve this answer























          • you broke it up in parts and then redefined the color. Thanks, for some reason I kept thinking that it wasn't possible.
            – MathScholar
            Dec 27 '18 at 15:44












          • @MathScholar, welcomed.
            – Sigur
            Dec 27 '18 at 15:49














          9












          9








          9






          Some improvements in the code.





          • standalone class to produce a single draw.

          • You can scope the lines to set the line width once.

          • You don't need to insert node in the bullets.


          • black is the default color, don't need to pass it to fill.


          enter image description here



          documentclass[tikz,margin=2mm]{standalone}

          begin{document}
          begin{tikzpicture}
          % Axes
          draw [-latex] (-1,0) -- (12,0) node (xaxis) [below] {$x$};
          draw [-latex] (0,-1) -- (0,6.5) node [left] {$y$};

          % Origin
          node at (0,0) [below left] {$0$};

          % Points
          coordinate (start) at (1,1.5);
          coordinate (1) at (3,.5);
          coordinate (2) at (5.5,4.5);
          coordinate (3) at (7.5,2.75);
          coordinate (end) at (9,6);

          % Plot
          begin{scope}[thick]
          draw [red] (start) to[out=-30,in=180] (1);
          draw [red!60!blue] (1) to[out=0,in=180] (2);
          draw [red!30!blue] (2) to[out=0,in=110] (3);
          draw [blue] (3) to[out=45,in=225] (end);
          end{scope}

          % show the points
          foreach n in {start,1,2,3,end}{%
          fill (n) circle (2pt);
          }
          end{tikzpicture}
          end{document}





          share|improve this answer














          Some improvements in the code.





          • standalone class to produce a single draw.

          • You can scope the lines to set the line width once.

          • You don't need to insert node in the bullets.


          • black is the default color, don't need to pass it to fill.


          enter image description here



          documentclass[tikz,margin=2mm]{standalone}

          begin{document}
          begin{tikzpicture}
          % Axes
          draw [-latex] (-1,0) -- (12,0) node (xaxis) [below] {$x$};
          draw [-latex] (0,-1) -- (0,6.5) node [left] {$y$};

          % Origin
          node at (0,0) [below left] {$0$};

          % Points
          coordinate (start) at (1,1.5);
          coordinate (1) at (3,.5);
          coordinate (2) at (5.5,4.5);
          coordinate (3) at (7.5,2.75);
          coordinate (end) at (9,6);

          % Plot
          begin{scope}[thick]
          draw [red] (start) to[out=-30,in=180] (1);
          draw [red!60!blue] (1) to[out=0,in=180] (2);
          draw [red!30!blue] (2) to[out=0,in=110] (3);
          draw [blue] (3) to[out=45,in=225] (end);
          end{scope}

          % show the points
          foreach n in {start,1,2,3,end}{%
          fill (n) circle (2pt);
          }
          end{tikzpicture}
          end{document}






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 27 '18 at 15:44

























          answered Dec 27 '18 at 15:40









          Sigur

          24k355137




          24k355137












          • you broke it up in parts and then redefined the color. Thanks, for some reason I kept thinking that it wasn't possible.
            – MathScholar
            Dec 27 '18 at 15:44












          • @MathScholar, welcomed.
            – Sigur
            Dec 27 '18 at 15:49


















          • you broke it up in parts and then redefined the color. Thanks, for some reason I kept thinking that it wasn't possible.
            – MathScholar
            Dec 27 '18 at 15:44












          • @MathScholar, welcomed.
            – Sigur
            Dec 27 '18 at 15:49
















          you broke it up in parts and then redefined the color. Thanks, for some reason I kept thinking that it wasn't possible.
          – MathScholar
          Dec 27 '18 at 15:44






          you broke it up in parts and then redefined the color. Thanks, for some reason I kept thinking that it wasn't possible.
          – MathScholar
          Dec 27 '18 at 15:44














          @MathScholar, welcomed.
          – Sigur
          Dec 27 '18 at 15:49




          @MathScholar, welcomed.
          – Sigur
          Dec 27 '18 at 15:49


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467553%2fchanging-color-in-coordinate-plot-in-tikz%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Сан-Квентин

          8-я гвардейская общевойсковая армия

          Алькесар