Add Whitespace to Plot

72 次查看(过去 30 天)
Georg Söllinger
Georg Söllinger 2016-10-4
编辑: dpb 2016-10-5
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

采纳的回答

dpb
dpb 2016-10-4
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 个评论
Georg Söllinger
Georg Söllinger 2016-10-5
Thank you dpb for your answer!
Your solution actually work but as a matter of fact I am not confident with the appearance of the graph. It is extremely squeezed, the aspect ratio doesnot look harmonic. I have a new idea: I would like to make another legend, which contains the boundary-strings and plots them 'southoutside' of the plot. The problem is, that I made the hatch-fills with several 'lines' in a for-loop. Is there a way to merge those lines in one element and adress this element to the string to generate a legend, which is like that one: [///////] Boundary-String.
Thanks in advance for your reply!
dpb
dpb 2016-10-5
编辑:dpb 2016-10-5
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by