Add Whitespace to Plot
77 views (last 30 days)
Show older comments
Dear Community,
I have a sort of uncommon problem: I have made a graph with matlab with a complexity-label (nothing quantitative) at the x-axis . In my graph there are filled regions, which are extended over the whole graph. At the right end of those areas I have added some text. The text juts out over the axis interval of the graph. If I adjust the width of the figure-window manually, everything fits onto the plot. But as I convert my graph with matlab2tikz and add it into my thesis and as the text is outside of the axis interval, the text is cut off and incomplete. I thought about adding some whitespace, but everything I can find is to eliminate the whitespace of figures.
I hope, anyone can help me with my problem, I'd truly appreciate it! Thanks in advance! Georg
Accepted Answer
dpb
on 4 Oct 2016
If I understand the issue, use the 'position' property and reduce the width value from its default to something less...that should give you more room on the RH side for the text before it runs into the 'outerposition' boundary.
pos=get(gca,'position'); % retrieve the current values
pos(3)=0.9*pos(3); % try reducing width 10%
set(gca,'position',pos); % write the new values
With HG2 in recent releases you can use the "dot" property notation.
See the doc for Axes Properties and links therein for all the gory details.
2 Comments
dpb
on 5 Oct 2016
Edited: dpb
on 5 Oct 2016
One very major shortcoming in Matlab graphics is the lack of builtin hatching functions. There are some submissions on the File Exchange that I've used but they all have warts of one kind or another. I don't know if there are any recent submissions that work with HG2 but I'd suggest a search there first to see about updates. It's been a couple years or more since I last used them.
ADDENDUM
I did a search again and uncovered something old I hadn't seen before but that might be useful given your application--it draws lines w/ hatch pattern on one side...
It's fairly old but has pretty good ratings. I don't think it'll doe legends though as I'm pretty sure it does just what you're doing except encapsulated.
A newer submittal is <hatchfill2> which uses a patch object to hatch and so it does work with legend with HG1. There are comments with it that another enhance legend function also on the file exchange may be able to be made to work with it.
TMW has really screwed legend up for anything out of the base functionality with HG2--they've made it almost totally opaque so one can't modify the pieces-parts that make up the display objects therein as one could with HG1 (albeit sometimes with great difficulty, but at least you could manage to usually get the job done).
I'd suggest looking at the above and see if get you closer to the end goal fairly quickly; the search I did is at <hatch&sort=ratings_desc>, you might look over that and see if anything else seems to stand out.
More Answers (0)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!