These routines allow easy plotting of lines or contours with hatches on one side. This line style is often used to represent a constraint, where one side of the line represents a no-go area.
Rob McDonald (2021). Hatched Lines and Contours (https://github.com/ramcdona/HatchedContours/releases/tag/1.7.0), GitHub. Retrieved .
Sarthak - give this update a try. It should work for loglog, semilogy, or semilogx plots. Plot needs to exist as a log-plot before you call into this -- i.e. this can't be the first command to a new plot window.
Sarthak - In the ~15 years since I wrote this, I don't think I've ever tried it on a log scale... Without trying it yet, I can imagine that it wouldn't work to much satisfaction.
The points are drawn in data coordinates, but to look good (consistent length hatches, getting the angle right, etc) they need to look right in pixel coordinates. This is why the aspect ratio parameter exists (AR) and why it is easier to add them to a pre-existing plot than make them the first lines on a plot that may be resized.
I'm not sure that there will be an easy way to fix this in Matlab. I will think about it, but I'm not very optimistic.
I also have a Java version of this implemented as a custom stroke for Graphics2D. I also recently wrote one for Python that will go out in Matplotlib when 3.4 is released in a few months. Both of these work more natively in pixel coordinates and should be fine for log scales. Let me know if you're interested in those.
been using this for years, but it has issues for plots with axes on a log scale. An update would be nice, or if I can get around to making an update/different version, I will try to post it somehow.
Theo - Quite correct, that is a bad habit left over from long ago.
Glad this was of use to you.
Very helpful. The only question I had was, in the example.m code, you use "c1=ocontourc(x1,x2',con1',[0 1e6]);" Why [0 1e6]? Should this not be [0 0]? It creates some artifacts near the origin.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!