I've got a the following to make a plot:
figure
plot(time,pres,'k');
xlabel('Time (s)');
ylabel('Pressure (Pa)');
grid on;
But how can I change the grid line colour from black to grey so that are less obtrusive?
Thanks
Hi Stuart, you can use set(gca,'Xcolor',..) and set(gca,'Ycolor',...)
time = 1:100; pres = randn(1,100);
plot(time,pres,'k');
xlabel('Time (s)');
ylabel('Pressure (Pa)');
grid on;
set(gca,'Xcolor',[0.5 0.5 0.5]);
set(gca,'Ycolor',[0.5 0.5 0.5]);
% Note the the X and Y ticks will be the same color as the grid lines, if you still want the tick marks black, you can do the following
Caxes = copyobj(gca,gcf);
set(Caxes, 'color', 'none', 'xcolor', 'k', 'xgrid', 'off', 'ycolor','k', 'ygrid','off');
Hope that helps,
Wayne
But this only partly works -- having created the second axes (and plot) these may or may not stay scaled exactly the same as the first axes, as the graph is resized.
Basically not a useful method when I tried it, but might be "good enough" in somce cases, especially of you go to more effort to disable all the parts of the second axes that you don't need.
All sympathies to the previous posters though -- having the gridline color is tied to the label color seems like a pretty dumb design.
Assuming that you are creating plots from your own code, this solution adds relatively little extra rubbish to your program, it's conceptually easy, and robust-ish.
The big solution is.... just turn off the official grid lines, and plot your own using one or another plot function, depending on the 2D or 3Dness of your plot!
If you set your axis limits and tick marks explicitly, then of course you already know where you need to plot the lines.
If you didn't, then your code has to do a bit more work to read XLim, YLim, and XTick and YTick from the axes.
-- Graham