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 commentaires

dpb
dpb le 19 Juil 2015
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 le 20 Juil 2015
dpb, R2015a is the release as mentioned in the question. please also see my response to Muhammad Usman Saleem below

Connectez-vous pour commenter.

Réponses (1)

Muhammad Usman Saleem
Muhammad Usman Saleem le 20 Juil 2015
%# 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 commentaires

Yale Brewer
Yale Brewer le 20 Juil 2015
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 le 20 Juil 2015
Modifié(e) : Muhammad Usman Saleem le 20 Juil 2015
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 le 20 Juil 2015
Modifié(e) : Muhammad Usman Saleem le 20 Juil 2015
if you resolve the problem then please accept my answer . thanks
Yale Brewer
Yale Brewer le 20 Juil 2015
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 le 20 Juil 2015
do not copy this image only save as in the tiff file format and see
Yale Brewer
Yale Brewer le 22 Juil 2015
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 le 22 Juil 2015
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 le 23 Juil 2015
please accept my answer if you understand the problem .Regards

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by