10

Using Gnuplot I plot the following graph -

Now, as you can see in the image, it is difficult between the lines, to identify the block at its end. So I will like to color the grid alternately with a different color, or style.

The code right now I use to color the grid is -

set style line 12 lc rgb '#808080' lt 0 lw 1
set grid back ls 12

However, I am not able to find any way to get the grid and set it alternately to another style. Is it even possible in Gnuplot?

What I mean is that, is it possible to have different line style for major and minor tics in grid of gnuplot?

Thanks !

enter image description here

Raj
  • 3,300
  • 8
  • 39
  • 67
  • I don't get your problem. If you want another style, use another style... `set style line 12 lc rgb 'red' lt -1 lw 2`. – Christoph Feb 04 '14 at 12:05
  • @Christoph I don't want another style. I was the first grid line of style1, second grid line of style2, then third one again of style1 and so on. I want them to be of alternating styles. – Raj Feb 05 '14 at 09:14

1 Answers1

17

Yes, you can use different styles for the minor and major grid lines, see help grid:

set style line 12 lc rgb 'blue' lt 1 lw 2
set style line 13 lc rgb 'red' lt 1 lw 1
set grid xtics ytics mxtics mytics ls 12, ls 13
set mxtics 4
set mytics 4
plot x

The result with 4.6.3 is:

enter image description here

Christoph
  • 47,569
  • 8
  • 87
  • 187
  • 2
    is there anyway of you breaking down the gnuplot code and explaining for people just getting into GNUPlotting? What does the 12 in 'set style line 12 ` resemble? – 3kstc May 26 '16 at 04:32
  • @3kstc The 12 is only a tag number for the line style which gets defined. Later you can refer to this line style using the tag as `ls 12` or `linestyle 12` – Christoph May 26 '16 at 06:18
  • @Cristoph Since it's a tag, I am asumiing it can be alphanumeric like `ls mystyle123` - also with the gnuplot how can I label every second minor grid tics? for example currently its (x-axies) with major x tics -10 -5 0 5 10, but what if I also wanted -7.5 -2,5 2.5 7.5 tics there included? what would that line of code look like? thanks in advance. – 3kstc May 27 '16 at 01:10
  • @3kstc No, as I wrote, it is a tag number, a number with the meaning of a tag. Regarding your question, see e.g. http://stackoverflow.com/a/19201774/2604213, I'd that doesn't help please ask a separate question – Christoph May 27 '16 at 14:44
  • Thanks! But line 3 should be `set grid xtics ytics mxtics mytics ls 12, ls 13`. Otherwise you won't get any `mxtics`-lines. – gilu Feb 21 '19 at 06:42