Search code examples
gnuplot

How to keep the colors pallete same inside the surface using gnuplot?


I am plotting a graph, attach is fig(1) with the lc palette, It is working well. However, when I am setting a box outside it, it changes all color to red only. How can I draw shapes outside the plot so that plot does not change its colors?

Note: I have to draw different shapes depending on crystal shapes not only a cube. I have a data file (data.dat) that has 4 columns and a second file(plot.dat) which has three columns(positions only) i am using the following command splot "data.dat" u 5:6:7:4 with l lw 4 lc palette notitle, "plot.dat" u 1:2:3 w l

[![fig:1[1] 2


Solution

  • The full range of colors cbrange in the palette is mapped to some particular range of z-values. By default it gets the same range as the z-values used in the plot. So in your first figure you can see that both the z values of the plot and the color values of the palette run from -0.6 to +0.6. Your plot command splot "data.dat" u 5:6:7:4 with l lw 4 lc palette takes a value from column 4, let's say 0, and looks up in the palette range what color that maps to. Since 0 is right in the middle of the cbrange, it gets assigned the midpoint color. In other words, the tic labels on the color bar tell you what range of colors will be used to map values taken from column 4. Apparently all of your column 4 values are near zero, since they all come out roughly the same color.

    In your second plot you must have taken z coordinates from a different place. Whatever it was, it is now being used to set different default limits to the range of palette colors cbrange. You can see that instead of [-0.6 : 0.6] the range has become [-0.05 : 0.01]. If you want to instead keep the same range of color values as your first plot, all you have to do is set that range explicitly rather than letting the program change it to match a new set of z values:

      set cbrange [-0.6 : 0.6]
    

    Typically if you are plotting a bunch of different data sets and want a consistent coloring, you would choose the cbrange in advance and set it to that for all the plots.