MATLAB figure/plot display issue

조회 수: 5 (최근 30일)
Yale Brewer
Yale Brewer 2015년 7월 19일
댓글: Muhammad Usman Saleem 2015년 7월 23일
plotting histograms or error bars for example, the bin divisions (the border to the bins) does not display, neither do for example error bars on a series of points plotted, yet if I copy the figure into say word or powerpoint, they are definitely there - even in the editor they do not show correctly even though they seem to be enabled.
anyone had this problem or no of a possible cause/solution? thank you in advance! (R2015a)
  댓글 수: 2
dpb
dpb 2015년 7월 19일
Show us what you've done and attach a figure with comment of what you expect but don't get. Oh, and with the new graphics engine, the Matlab release would be good to know.
Yale Brewer
Yale Brewer 2015년 7월 20일
dpb, R2015a is the release as mentioned in the question. please also see my response to Muhammad Usman Saleem below

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

답변 (1개)

Muhammad Usman Saleem
Muhammad Usman Saleem 2015년 7월 20일
%# random data
a = [(1:30)' rand(30,1)]; %'#
%# compute edges (evenly divide range into bins)
nBins = 10;
edges = linspace(min(a(:,2)), max(a(:,2)), nBins+1);
%# compute center of bins (used as x-coord for labels)
bins = ( edges(1:end-1) + edges(2:end) ) / 2;
%# histc
[counts,binIdx] = histc(a(:,2), edges);
counts(end-1) = sum(counts(end-1:end)); %# combine last two bins
counts(end) = []; %#
binIdx(binIdx==nBins+1) = nBins; %# also fix the last bin index
%# plot histogram
bar(edges(1:end-1), counts, 'histc')
%#bar(bins, counts, 'hist') %# same thing
ylabel('Count'), xlabel('Bins')
%# format the axis
set(gca, 'FontSize',9, ...
'XLim',[edges(1) edges(end)], ... %# set x-limit to edges
'YLim',[0 2*max(counts)], ... %# expand ylimit to accommodate labels
'XTick',edges, ... %# set xticks on the bin edges
'XTickLabel',num2str(edges','%.2f')) %'# round to 2-digits
%# add the labels, vertically aligned on top of the bars
hTxt = zeros(nBins,1); %# store the handles
for b=1:nBins
hTxt(b) = text(bins(b), counts(b)+0.25, num2str(a(b==binIdx,1)), ...
'FontWeight','bold', 'FontSize',8, 'EdgeColor','red', ...
'VerticalAlignment','bottom', 'HorizontalAlignment','center');
end
%# set the y-limit according to the extent of the text
extnt = cell2mat( get(hTxt,'Extent') );
mx = max( extnt(:,2)+extnt(:,4) ); %# bottom+height
ylim([0 mx]);
I hope you are looking for this:
  댓글 수: 8
dpb
dpb 2015년 7월 22일
One thing to try with these kinds of issues is to change the 'renderer' property for the figure and see if that makes a difference.
You can also see if there is an updated driver for the particular graphics card from the vendor; on the rare occasion that has helped here (altho it's been years since that was such an issue it seems as in days of yore).
I'd suggest this may be a fignewton of the new graphics engine; submit the problem with sample code to official support at www.mathworks.com I don't have the later versions (not enough memory/horsepower) so can't check out anything w/ HG2 directly.
Muhammad Usman Saleem
Muhammad Usman Saleem 2015년 7월 23일
please accept my answer if you understand the problem .Regards

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by