I'm using gnuplot to make a colour-map. What I need is, when I set a palette I need to define the ranges and colours such that certain ranges have the same colour.
For example, say the third column of the data ranges from 100 to 150. I need 100 to 120 to be same colour, then 120 to 130 same colour. I tried doing it this way
set palette defined (100:120 "gray", 121:129 "blue", 130:150 "dark-gray")
But it gnuplot says this is invalid expression, specifically pointing at the " : ".
Is there any way around this?
check out set palette maxcolors. From the help page:
This option can also be used to separate levels of z=constant in discrete
steps, thus to emulate filled contours. Default value of 0 stays for
allocating all remaining entries in the terminal palette or for to use exact
mapping to RGB.
Also note that you should be able to do something like:
set palette defined ( 100 "gray", 120 "gray", 121 "blue", 129 "blue" )
but be careful -- the numbers 100, 120, 121, 129, etc don't correspond to the values on your colorbar unless you set cbrange [100:129] (for example).
Related
I have a rather specific problem. I want to plot a electronic difference density using splot. The gridfile contains values from around -5 to up to 25. However, I am only interested in small values to find nodelines. So I would like to set palette such, that everything that is smaller/larger than the lower/upper boundary has the boundary color.
Here is what I use:
set key off
set view map
set palette defined (-0.01 'blue', 0 'white', 0.01 'red')
splot [][][-0.01:0.01] 'gridfile.dat' matrix with points pointtype 5 palette
That gives me almost what I want - but instead of coloring the out of range points with the colors of the boundaries gnuplot just does nothing (so I get the color of the background there).
I tried fiddling around with cbrange, because according to the manual, that should do what I need:
Cbrange
The set cbrange command sets the range of values which are colored using the current palette by styles with pm3d, with image and with palette. Values outside of the color range use color of the nearest extreme.
However, that has not worked so far and I am running out of ideas (and out of possible google-searches).
Does anybody know how I could solve this?
set cbrange is indeed what you are looking for, but not what the third bracket pair [-0.01:0.01] for splot does: that is the zrange. Use
set key off
set view map
set palette defined (-0.01 'blue', 0 'white', 0.01 'red')
set cbrange [-0.01:0.01]
splot 'gridfile.dat' matrix with points pointtype 5 palette
Say we got this data 'file.dat':
0.1 2
0.5 1
0.7 3
1.3 23
1.4 20
2.7 2
2.3 6
5.3 50
5.2 50
I wish to plot this as follows:
2D plot (lines is fine), like normal.
Except: xtics label shows the following names instead: "small", "medium", "big" marked exactly at x values 0, 3 and 5, respectively.
Q: How to achieve this?
Permissible actions:
I can modify existing or create new 'file.dat' files.
I can modify gnuplot commands.
set xtics ("small" 0, "medium" 3, "big" 5)
plot 'file.dat' with lines lw 2 lc rgb "black"
should work.
For more information type help xtics:
The explicit ("" , ...) form allows arbitrary tic
positions or non-numeric tic labels. In this form, the tics do not
need to be listed in numerical order. Each tic has a position,
optionally with a label. Note that the label is a string enclosed by
quotes. It may be a constant string, such as "hello", may contain
formatting information for converting the position into its label,
such as "%3f clients", or may be empty, "". See set format for more
information. If no string is given, the default label (numerical) is
used.
An explicit tic mark has a third parameter, the level. The default
is level 0, a major tic. Level 1 generates a minor tic. Labels are
never printed for minor tics. Major and minor tics may be
auto-generated by the program or specified explicitly by the user.
Tics with level 2 and higher must be explicitly specified by the user,
and take priority over auto-generated tics. The size of tics marks
at each level is controlled by the command set tics scale.
Examples:
set xtics ("low" 0, "medium" 50, "high" 100)
set xtics (1,2,4,8,16,32,64,128,256,512,1024)
set ytics ("bottom" 0, "" 10, "top" 20)
set ytics ("bottom" 0, "" 10 1, "top" 20)
I have a plot with:
xtics = {0, 2000, 4000, ..., 20000}
and I would like them to be shown as:
0 2 4 ... 20
x 10^3
Is there any way to do so?
You can do so by setting a label at the appropriate position:
set label 1 "× 10³" right at graph 1, -0.05
This would place the text × 10³ right aligned with the right border of your plot and somewhat below it. You probably have to adjust the vertical position (−0.05) a bit depending on your plot.
However, I recommend against indicating factors like that and suggest to incorporate them in the axis label and use set xlabel "amount [10³ potatoes]" for example. The kind of labels you want to use are easy to miss and fortunately not common anymore.
I would like to have a color bar divided into 5 colors. One color from 0 to 20, another until 40, and so on until 100.
What I have done so far is:
set palette maxcolors 5
But this doesn't set the boundries of each color in the colorbar
Do you have suggestions?
To avoid setting the boundaries manually, you're on the right track. What might help is to set the color bar's range:
set cbrange [0:100]
That way the palette will be divided into 5 colors just between 0 and 100, instead of having the limits determined by the data/function being plotted.
I am trying to create a barchart using gnuplot. My requirement is that I should be able to label y-axis as 0, 1, 100, 10,000 (i.e., each tick increases by a factor of 100, except between 1 and 0). Also, this is not log-scale as I want this to start at 0. Let me know if you know how to do this.
You can use set xtics:
gnuplot> set xtics ("0" 1, "1" 2, "100" 3, "10000" 4)
gnuplot> plot "test.dat" notitle with boxes
produces the following plot:
http://marco.uctleg.net/resources/sample_xtics.png
with the following data:
1 12
2 8
3 19
4 42
EDIT: Just noticed you asked to change the y-axis. It's much the same, I'm sure you can work it out.
Marcog's answer is probably the best way to get exactly what you want,
However, if you don't want to do the reassignment of 1 means "0", 2 means "1" etc,
then you could try a simple
set ytics (0,1,100,10000)
To set the tics where you want them,
and then use the set format y to specify the format of the tics.
For example
set format y "10^{%L}"
to put the tics in nice exponential form (note this particular formatting looks pretty in postscript output, but rather ugly in the default gnuplot window).
See http://t16web.lanl.gov/Kawano/gnuplot/tics-e.html for more on the set format command (midway down the page).
All the best