4
$\begingroup$

I wanna plot 2 gridlines in colors. One in red. Other in blue. How to do it?

Wrong code:

Plot[{x, x^2}, {x, 0, 1}, GridLines -> {{0.25, 0.5}, {}}, GridLinesStyle -> {{ {Red, Blue}}, {}}]

enter image description here

$\endgroup$
  • 4
    $\begingroup$ Take a look at ref / GridLines / Details, you can just use GridLines -> {{{0.25, Red}, {0.5, Blue}}, {}} $\endgroup$ – Kuba Jun 14 '17 at 20:42
3
$\begingroup$
GridLinesStyle -> {{Red},{ Blue}}

As described here.

$\endgroup$
  • $\begingroup$ This does not work in v11.2.0 $\endgroup$ – Anti Earth Oct 31 '18 at 14:34
4
$\begingroup$

The previous solutions no longer seem to work (in v11.2.0). However, you can style each gridline individually inside GridLines like so:

Plot[
    {x, x^2}, {x, 0, 1}, 
    GridLines -> {
        {{0.25, Red}, {0.5, Blue}}, 
        {}
    }
]

Any additional styling in GridLinesStyle will also apply and override. Note this includes the default styling (seems to be lowered opacity) if you don't specify GridLinesStyle!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.