Fill, Alpha, Datenum: what is the problem?

조회 수: 13 (최근 30일)
Davide Luigi Perego
Davide Luigi Perego 2015년 5월 20일
댓글: Davide Luigi Perego 2015년 5월 20일
Good morning, I am trying to plot a transparent box in a plot where the X-axis is time. I have problems when I enable the "Alpha" flag, check the piece of code I attach here. Any suggestion about a possible workaround? The problem appears only when I use timestamp, otherwise it is ok. Thanks in advance! Best regards Davide
x1 = '20-May-2015 07:28:06';
x2 = '20-May-2015 07:38:06';
x3 = '20-May-2015 07:00:00';
x4 = '20-May-2015 08:00:00';
figure();
fill([datenum(x1),datenum(x2),datenum(x2),datenum(x1)],...
0.0,0.0,5.0,5.0],1-0.3*(1-[1 0 0]),'FaceAlpha',0.5);
grid on;
hold on;
plot([datenum(x3) datenum(x4)],[0.0 .5],'.-r','MarkerSize',12,'Linewidth',2.0);
datetick('x',15,'keepticks');
axis([datenum(x3) datenum(x4) -2.0 +7.0]);

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 20일
When you use FaceAlpha, that forces the use of the OpenGL renderer. Without it, you are getting the Painters renderer. OpenGL can have difficulty when the axis values are very close together.
If you do not need to use a DataCursor, the workaround is to shift and scale the values you use for the X axis so that they are numerically further apart, then set the XTick according to the shifted and scaled values, and then set the XTickLabel property according to what you would want the user to see at those locations. For example you might datevec() to extract the hours, minutes, seconds for the places you would like ticks, and sprintf() the parts together to get a tick label.
  댓글 수: 1
Davide Luigi Perego
Davide Luigi Perego 2015년 5월 20일
Hi Walter, thanks for your quick reply. Unfortunately it is not completely clear. Is it not possible to set the Painters rendere instead? I copy below the specs of my openGL rendere. Thanks Davide
>> opengl info
Version = 4.2.12352 Compatibility Profile Context 13.101.1.0
Vendor = ATI Technologies Inc.
Renderer = AMD Radeon HD 8750M
MaxTextureSize = 16384
Visual = 02 (RGB 32 bits(08 08 08 08) zdepth 24, Hardware Accelerated, Opengl, Double Buffered, Window)
Software = false
  1. of Extensions = 241
Driver Bug Workarounds:
OpenGLBitmapZbufferBug = 0
OpenGLWobbleTesselatorBug = 0
OpenGLLineSmoothingBug = 0
OpenGLDockingBug = 0
OpenGLClippedImageBug = 0
OpenGLEraseModeBug = 0

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by