6
$\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$
1
  • 5
    $\begingroup$ Take a look at ref / GridLines / Details, you can just use GridLines -> {{{0.25, Red}, {0.5, Blue}}, {}} $\endgroup$
    – Kuba
    Commented Jun 14, 2017 at 20:42

2 Answers 2

3
$\begingroup$
GridLinesStyle -> {{Red},{ Blue}}

As described here.

$\endgroup$
1
  • 1
    $\begingroup$ This does not work in v11.2.0 $\endgroup$
    – Anti Earth
    Commented Oct 31, 2018 at 14:34
9
$\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 and acknowledge you have read our privacy policy.

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