Wednesday, November 10, 2010

no tick on one side of the axis.

https://groups.google.com/group/comp.soft-sys.matlab/browse_thread/thread/824cb990c0c51e1?hl=en

Set XTickMode and YTickMode to 'manual',
set XTick and YTick to the empty vector, [],
then draw the tick marks in "by hand".
There is no Axes Property in Matlab that would give you the
tick style you are asking for.
Alternately.... once you have drawn the plot,
get(gca,'Color') to find the background colour
get(gca,'XLim') to find the x data range
get(gca,'YLim') to find the y data range
now draw a patch() rectangle near the top of the plot, using
the fetched colour as the patch colour;
Use a minimum X just slightly bigger than the lower limit of the
X data {about XLim(1) + 0.003 * (XLim(2) - XLim(1)) seems to work},
Use a maximum Y just slightly lower the the upper limit of the
Y data {about YLim(2) - 0.003 * (YLim(2) - YLim(1) seems to work}.
It appears that you can use a maximum X which is the same as the
XLim(2).
The minimum Y is not critical -- big enough to cover up the tick
marks, {about YLim(2) - 0.03 * (YLim(2) - YLim(1) seems to work}.
Set the 'EdgeColor' property of the patch to 'none'.
You can specify the patch using four vertices for the rectangle, as
it will be closed automatically, but I prefer not to rely on the
automatic closing.
[xmin xmax xmax xmin xmin], [ymin ymin ymax ymax ymin]
Repeat the same process, drawing a patch() rectangle near the
right side of the plot, again using the fetched colour as the patch
colour, using similar margins as for the above case.
Now the final trick:
axchild = get(gca, 'Children');
set(gca, 'Children', [axchild(3:end) axchild(1:2)]);
what this does is take the two patches you just created, and push them
underneath everything else you drew on the plot. They will still be
above the tick-marks and so will still hide the tick marks, but they
will be below the rest of your graphics. That's why the rectangle
thicknesses are not important -- the rectangle will be pushed under
the other graphics.
But the 0.003 margins I mentioned are still needed: without them, the
patch will cover over part of the box. You may need to play with the
0.003 figure; probably a better figure would be 1.25 pixels-worth of
the figure size (set the figure units to pixels and get its Position
and look at the 3rd and 4th entries to get the sizes in pixels). If
your margins are too small then part of the plot box will be obscured;
if your margins are too big, then part of the tick marks will be
left showing.

No comments: