how to use a color scheme with the “plot function” ?

DataGraph Forums › Technical Support › Support Desk › how to use a color scheme with the “plot function” ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #15518
    nautile
    Participant

      Hello ! I’m setting up some classroom demos of different population dynamics functions using the function plotting tool and I can’t seem to find the trick for how to use a color scheme global variable to control the line color – is this possible ?

      Here’s an example image – the top plot uses the plot function (where I set the colors manually) and the bottom one is built with the cross-model example available in the online examples …Jennifer

      FigXX_Hassell_model_v0

      #15519
      dgteam
      Moderator

        To use a global color scheme, with a line plot you can do it using a connect command (the standard plot command does not have this).

        For an example, see the example file Line plot with color scheme:

        lineplotcolorscheme

         

        This example shows how to use the Connect command to specify each line segment and then use a column to define the line color.  In the processing group, the row values are incremented by one to get each line segment in a row.

        connectlines

         

        That can work, but if you plan to use one of the built-in color schemes (it looks like that is what you have here), you can use a Plots command for data with a single x column and multiple y columns.

        Here is a screenshot from the multicolor line plot example. Click on the gear menu to get a list of color suggestions.

        plotscommand

        To plot your data initially with the plots command is also pretty quick. You can select all the columns, the X column, and all the Y columns at once, then add the plots command.

        Do you think the Plots command will work for your data?

         

         

        #15520
        nautile
        Participant

          Hello ! Yes – I did try out that example, that’s partly how I did an earlier version of the lower plot.

          But the upper plot uses the function command only – no points. That’s where I couldn’t get the color to associate with a global color scheme – what am I missing ??

          Jennifer

          Screenshot 2025-02-18 at 18.24.05

          #15521
          dgteam
          Moderator

            Ah, sorry, I misunderstood. The function command does not have a color scheme option, but you could use the Functions you have set up and evaluate them in the data table. Then use the Plots command.

            Note that you could use an expression to perform the calculation in the data table, but since you already have the Function commands set up, you don’t have to.

            Instead, you can use a Plot action column with the option to “Evaluate” a function from a command.

            For example, three functions are drawn here, where the value for A varies.

            functions

             

            Using the Other menu, the Plot action column is added from the data side panel.

            AddPlotAction

             

            You will also need an Expression column to generate x values (here, the column x1 is set to “(#-1)/100”).

            In the Plot action column, set the Action to “Evaluate”. Then, you will have a menu below to specify the function.  You can use the menu or drag and drop from the function command to the menu in the plot action column.

            PlotactionEval

            Then, select all the columns and add a single Plots command. Use the gear menu as previously described to select the color scheme.

            Plots

            Let us know if this works! If you are unsure, you can also email the file to our help email.

             

            #15522
            nautile
            Participant

              That’s a nice trick at the end with using the multiple lines plot – that works for me – thanks ! 🙂

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.

            DataGraph Forums › Technical Support › Support Desk › how to use a color scheme with the “plot function” ?