MATLAB figure/plot display issue
이전 댓글 표시
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
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
2015년 7월 20일
답변 (1개)
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
Yale Brewer
2015년 7월 20일
Muhammad Usman Saleem
2015년 7월 20일
편집: Muhammad Usman Saleem
2015년 7월 20일
ok . then save histrogram figure in tiff file format and then copy it into world. This will save quality of the matlab image.
Muhammad Usman Saleem
2015년 7월 20일
편집: Muhammad Usman Saleem
2015년 7월 20일
if you resolve the problem then please accept my answer . thanks
Yale Brewer
2015년 7월 20일
Muhammad Usman Saleem
2015년 7월 20일
do not copy this image only save as in the tiff file format and see
Yale Brewer
2015년 7월 22일
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
2015년 7월 23일
please accept my answer if you understand the problem .Regards
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

