Can't show grid in plot

25 ビュー (過去 30 日間)
Joakim Magnusson
Joakim Magnusson 2014 年 8 月 15 日
編集済み: Joakim Magnusson 2014 年 8 月 15 日
I'm trying to make grids in my plot, i have other simpler plots where i manage to show grids, but not in this plot:
%The AXES command selects the set of axes to plot in,
axes(handles.viewCAM_handles.axes_accVelRatio);
% Plot velV and accV ratio with centered x and y axis
[AX] = plot(velV, accV);
grid on;
set(AX, 'LineWidth', 2);
xlabel('Velocity');
ylabel('Acceleration', 'Color', 'b');
xMax = max([max(velV) abs(min(velV))]);
yMax = max([max(accV) abs(min(accV))]);
if xMax >= 1
xMax = ceil(xMax);
else
xMax = round(xMax*10)/10;
end
if yMax >= 1
yMax = ceil(yMax);
else
yMax = round(yMax*10)/10;
end
axis([-xMax xMax -yMax yMax]);
y=get(gca,'ytick');
x=get(gca,'xtick');
hold on
Lx=line([x(1) x(length(x))],[0 0]);
Ly=line([0 0],[y(1) y(length(y))]);
set(Lx,'color','k');
set(Ly,'color','k');
for i=1:length(x)
plot(x(i),0,'kx');
text(x(i),-.01,num2str(x(i)));
end
for i=1:length(y)
plot(0,y(i),'kx');
text(-0.5,y(i),num2str(y(i)));
end
grid on;
set(gca,'yticklabel',[],'xticklabel',[],'ytick',[],'xtick',[]);
I'm setting origo in the middle of the plot and i draw lines for that, i think the problem has something to do with that. Any ideas?
My plot look like this:
  1 件のコメント
Joakim Magnusson
Joakim Magnusson 2014 年 8 月 15 日
I debugged the code and before the last line of the code i posted, the grid is showing, but not after the last line.

サインインしてコメントする。

採用された回答

Adam
Adam 2014 年 8 月 15 日
If you set all the ticks to empty you will have no grid by definition as the grid is defined to be at the tick locations
  1 件のコメント
Joakim Magnusson
Joakim Magnusson 2014 年 8 月 15 日
編集済み: Joakim Magnusson 2014 年 8 月 15 日
Thx, changing the last line to this fixed it:
set(gca,'yticklabel',[],'xticklabel',[]);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by