Can I create a custom background for a plot?

조회 수: 13 (최근 30일)
Ryan
Ryan 2017년 8월 26일
편집: Jan 2017년 8월 27일
Hello all,
I like to turn my axes and markers off like this:
set(gca,'Visible','off')
Then I change the background to a certain color. My question is can you make the background multicolored? i.e. the color fades from white to black top to bottom or something along those lines. My first instinct is just make an image and put it behind the data I'm plotting, but I was hoping you guys might now of a better way.
If I do have to go the image route what is the code to hide it behind the data. uistack? What would that look like?
Thanks! And let me know if this question needs more explanation.
-Ryan

채택된 답변

Jan
Jan 2017년 8월 27일
편집: Jan 2017년 8월 27일
Which background? Of the axes or the complete figure? This creates a 2nd axes containing a grey ramp behind an invisible axes containing a 2D diagram:
figure;
AxesH = axes('Visible', 'off', 'NextPlot', 'add'); % Axes for diagrams
plot(1:10, rand(10, 10), 'LineWidth', 3);
set(AxesH, 'units', 'pixels'); % Get size in pixels
Pos = get(AxesH, 'Position');
ramp = repmat(linspace(1, 0, Pos(4)).', 1, Pos(3)); % Create gray ramp
ImgAxesH = axes('Visible', 'off'); % Axes for background
imshow(ramp, [], 'Parent', ImgAxesH); % Show ramp
uistack(AxesH, 'top'); % Diagram to the top
  댓글 수: 2
Ryan
Ryan 2017년 8월 27일
Winner! Thanks Jan you are the best.
Jan
Jan 2017년 8월 27일
Thanks Ryan. You are the winner, because this is your thread. :-)

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 8월 27일
Yes, you could use uistack() to hide the image behind everything else, provided the other items had non-negative Z values. If you are doing 3D plots then you will need to do more work, to texture map the image onto a surface or patch and ensure that the patch is always perpendicular to the line of sight and "behind" all objects.
There is no built-in provision for multicolored backgrounds.

카테고리

Help CenterFile Exchange에서 Propagation and Channel Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by