필터 지우기
필터 지우기

Add Whitespace to Plot

조회 수: 80 (최근 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
  댓글 수: 1
Georg Söllinger
Georg Söllinger 2016년 10월 4일
This is the discussed picture:

댓글을 달려면 로그인하십시오.

채택된 답변

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에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by