Built-in colorbar feature causes it to overlap with plot....

조회 수: 17 (최근 30일)
plasmageek
plasmageek 2020년 5월 19일
댓글: plasmageek 2020년 5월 28일
So in the matlab help file for Colorbar, it shows an example where all labels can be shifted to the left side of the colorbar. However, matlab apparently doesn't take into account the text and ticks when setting up the position. So now the text overlaps my plot. This is program breaking. I found a really old post that used a property to try to fix this, but the property no longer exists. Is there a new property to fix this or is colorbar just really that....stupid? Also, is the position property for colorbars setup differently than [startX startY width height]? It seems completely off it's rocker. (the SF6 you can barely see is supposed to be sitting at the edge of the colorbar, but using the colorbar position values puts it way out in no-man's land).
Using 2018a.

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 5월 19일
편집: Ameer Hamza 2020년 5월 19일
Try something like this. The position property is setup same as [startX startY width height]
ax = axes();
c = colorbar();
c.AxisLocation = 'in';
title(c, 'myTitle');
c.Position(1) = c.Position(1)+0.06; % shift a bit to right
ax.Position(3) = ax.Position(3)-0.05; % decrease width of axes a bit
  댓글 수: 1
plasmageek
plasmageek 2020년 5월 28일
So while this is what I did, it's a poor bandaid and I was avoiding it. The shifts change based on figure and text size and this is a code I use to plot lots of different data sizes.
The position values returned for colorbar just seem wrong and I don't understand what they're actually giving. Here's an example in the 'default' case. I took the positionals from the colorbar and placed my annotation at the start-x position, and start-y/start-y+height. The x-position starts to the right of the colorbar, and almost looks like it aligns with the text. But this isn't the case when text is on the left side of the colorbar, so it's almost like it's marking the end of the colorbar instead?
This may really be a question for mathworks instead of the forums.

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

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by