2

I'm struggling to figure out how to change the grid line colours in a polar plot in MATLAB. I tried to manually change some axes properties that could possibly do that, but couldn't observe any changes. Just to be clear: It's not about the axes themselves, but the grid lines (inner circles) that are drawn for orientations should be black (or have a better contrast) since this light grey is suboptimal for e.g. a presentation shown with a projector.

enter image description here

How can I change the colour of the grid itself?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
MD98
  • 344
  • 2
  • 9
  • There seems to be an option within the axes called `GridColor`, which you could set to `[0 0 0]`, i.e. black. Something like `ax = plot(1:10); ax.GridColor = [0, 0, 0]`. (I can't test this, as my MATLAB is old). Otherwise, you could manually draw a circle on each of the tick-radii and colour that by hand (which is the only way to set the grid to *different* colours as far as I can find) – Adriaan Nov 09 '22 at 13:11
  • 2
    The way to do it differs considerably whether you are using `polar()` (old version) or `polarplot()` to generate the graph. Please indicate which function you are using. – Hoki Nov 09 '22 at 13:26
  • @Hoki Thanks for noticing. I added a note in my answer – Luis Mendo Nov 09 '22 at 13:30
  • @Adriaan I actually tried that, but nothing in the plot changed. Probably didn't do it quite right. – MD98 Nov 10 '22 at 13:29

1 Answers1

5

Assuming you are using polarplot (note that polar is not recommended), you need to set the GridColor and GridAlpha properties of the axes. These properties control color and transparency, respectively. For pure, non-transparent black use

set(gca, 'GridColor', [0 0 0], 'GridAlpha', 1)
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
  • 1
    I actually was using `polarscatter`, didn't think this would matter. However, this line worked for me just fine! Thank you very much. – MD98 Nov 10 '22 at 13:28
  • @MD98 I see. I was thinking that black grid lines would perhaps look too strong compared to a plotted curve (`polarplot`), but with markers (`polarscatter`) they make more sense – Luis Mendo Nov 10 '22 at 13:45