Info

This question is closed. Reopen it to edit or answer.

How can I have thicker axis lines on only certain values using surfc?

1 view (last 30 days)
I'm using surfc to plot a 42x42 graph, which is then viewed from the top down. There is a meaningful difference between every 7 values, and as such I would like the x and y axis lines to be thicker for every 7th value (i.e. 7,14,21,28...). This would create a 7x7 grid within the 42x42. Is there an easy way to do this?

Answers (1)

Ben11
Ben11 on 28 Jul 2014
Edited: Ben11 on 28 Jul 2014
Here is a simple way, drawing line objects at evenly spaced locations on your axis. I generate a dummy 2D plot but you can do the same with your surfc plot:
clear
clc
x = 1:15*pi; % dummy data to plot
A = 0:7:42; % generate regularly spaced values.
plot(abs(42*sin(x)));
xlim = get(gca,'XLim'); % get axis x limits
ylim = get(gca,'YLim'); % get axis y limits
hold all
for k = 1:7 % number of lines
line('XData',[A(k) A(k)],'YData',[ylim(1) ylim(2)],'LineWidth',1.5);% vertical lines
line('XData',[xlim(1) xlim(2)],'YData',[A(k) A(k)],'LineWidth',1.5); %
end
set(gca,'XLim',[0 42],'YLim',[0 42],'XTick',0:7:42,'YTick',0:7:42);
hold off
This results is the following:
Hope that helps! Note that you can also use
grid on
to visualize dotted gridlines.
If it's not what you meant please ask!
  3 Comments
Ben11
Ben11 on 28 Jul 2014
Yes you can set the gridlines to full instead of dashed with this after your first call to plot:
set(gca,'gridlinestyle','-')
and then replace the last 2 lines of my answer with these:
set(gca,'XLim',[0 42],'YLim',[0 42]'XTick',0:1:42,'YTick',0:1:42);% i.e. remove the change to'XTick' and 'YTick'
hold off
grid on
Then your grids will appear full and the thicker lines added in the loop will as well. Is it what you mean? If not please ask :)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!