Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 3 (최근 30일)
Arran
Arran 2014년 7월 28일
마감: MATLAB Answer Bot 2021년 8월 20일
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?

답변 (1개)

Ben11
Ben11 2014년 7월 28일
편집: Ben11 2014년 7월 28일
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
Ben11
Ben11 2014년 7월 28일
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 :)
Ben11
Ben11 2014년 7월 30일
@Arran so does it work?

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by