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
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일

0 개 추천

%# 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
Yale Brewer 2015년 7월 20일
this gives what I am looking for, however is rather long-winded - I have been using the histogram(data) function, which appears like this
but when it is copied, (edit -> copy figure) and pasted into word or similar it appears like this, with the bar divisions visible. This is just straight plotting - I can change the division color, and it will copy with the correct color, but still fail to display the change in the figure window.
Muhammad Usman Saleem
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
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
Yale Brewer 2015년 7월 20일
yes if I save the file or copy it, the lines miraculously appear, but it is impossible to tell how a figure looks before you export it - another example would be the errorbar function which exhibits the same issue!
it unfortunately does not resolve the issue - I want to be able to see the lines within the figure window
Muhammad Usman Saleem
Muhammad Usman Saleem 2015년 7월 20일
do not copy this image only save as in the tiff file format and see
Yale Brewer
Yale Brewer 2015년 7월 22일
yes saving as tiff still produces the lines, it is a problem within matlab or access to hardware I can't quite fathom i.e. the figure window does not render the output correctly
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

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

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

질문:

2015년 7월 19일

댓글:

2015년 7월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by