Seems like a really great tool but unfortunately I don't manage to get it working for the problem I needed it for:
I have a 2D-matrix of linear trends (slopes) and a logical 2D-matrix of the same size telling whether the trend is significant at position xy. Now I'd like to hatch the regions of (no) significance in a contourf or pcolor plot.
Has anyone any hint why it does not work in this case although I get it working in other cases?
aaaand if you want the aspect ratio of the hatch pattern to be correct you need to pass the axes handle to the hatch_xy function and replace calls to gca.
nasty, but works:
function [xi,yi,x,y]=hatch_xy(hax,x,y,varargin);
gca = hax;
(and of course updating the relevant hatch_xy call line)
hLegend = legend(...);
hp = findobj(hLegend, 'Type', 'patch');
hatchfill(hp)
This assumes you have only one patch; you need to specify hp(i) in the hatchfill call when there are multiple patches. Also, I've found you need to increase the SPACING parameter for it to look good.
Seems like a really great tool but unfortunately I don't manage to get it working for the problem I needed it for:
I have a 2D-matrix of linear trends (slopes) and a logical 2D-matrix of the same size telling whether the trend is significant at position xy. Now I'd like to hatch the regions of (no) significance in a contourf or pcolor plot.
Has anyone any hint why it does not work in this case although I get it working in other cases?
Would be very grateful for help.
Cheers
Comment only
02 May 2013
Hatchfill
Fills an area with hatching or speckling.
aaaand if you want the aspect ratio of the hatch pattern to be correct you need to pass the axes handle to the hatch_xy function and replace calls to gca.
nasty, but works:
function [xi,yi,x,y]=hatch_xy(hax,x,y,varargin);
gca = hax;
(and of course updating the relevant hatch_xy call line)
Comment only
02 May 2013
Hatchfill
Fills an area with hatching or speckling.
I _believe_ the problem with legend hatching is that the lines are being drawn on the wrong axes.
If you adjust the calls to 'line' in the function to specify the axes parent then it seems to work... at least for me (R2011b).
-----------------------------------------
H(j) = line(xhatch,yhatch,'marker','.','linest','none', ...
'markersize',specksize,'color',linec,'parent',hax);
and
H(j) = line(xhatch,yhatch,'parent',hax);
-----------------------------------------
%My legend code:
hLegend = legend(...);
hp = findobj(hLegend, 'Type', 'patch');
hatchfill(hp)
This assumes you have only one patch; you need to specify hp(i) in the hatchfill call when there are multiple patches. Also, I've found you need to increase the SPACING parameter for it to look good.
5
22 Feb 2013
Hatchfill
Fills an area with hatching or speckling.
Comment only