From: Thomas on 1 Jul 2010 07:06 Hello everybody, I am experiencing some strange behaviour regarding the BackgroundColor of text-objects. The DrawSomeBars function below takes four input arguments which specify the heights, widths (ranges) and colors of bars which are to be drawn in a figure. I am doing this because the bars have different widths. It also places texts that correspond to the bars. These texts all get a black edgecolor and a white backgroundcolor. Finally the function prints the figure in a png file Everything works fine until I rearrange the texts in the figure (using the-"edit plot"-arrow for drag and drop). While the output on the screen is fine - text in front drawn over text in the back - printed png's of the modified figure aren't. Here the texts are transparent, as though the backgroundcolor wasn't defined (even if I define e.g. a red backgroundcolor). There seems to be a connection whether I use MATLAB or Ghostscript graphic formats (Ghostscript producing results as shown on the screen). Using different renderers does not influence the result. Has anyone an idea how to fix this behaviour and why MATLAB fails to print the image as shown on the screen? Thanks in advance Thomas % heights = (X,1) X bar heights % ranges = (X,2) X bar ranges/widths (width definied by a starting and ending x-coordinate) % colors = (X,3) rgb-values for X bars % texts = {X} cell-Array containig X texts function DrawSomeBars(heights,ranges,colors,texts) Fontsize=11; Fontname='Arial'; % open figure fig=figure('paperpositionmode','auto','units','centimeters','Inverthardcopy','off'); set(fig,'position',[2 2 16.05 9.24],'color',[1 1 1]) hold on % draw bars for i=1:size(heights,1) bar((ranges(i,1)+ranges(i,2))/2,heights(i,1),ranges(i,2)-ranges(i,1),'facecolor',colors(i,:),'edgecolor',[0 0 0]) end % setting some things (xtickMode back to auto, because bar seems to inflict some changes here) set(gca,'xtickMode','auto','FontName',Fontname,'Fontsize',Fontsize,'box','on','YGrid','off','GridLineStyle','-') xlabel('Primärenergieeinsparungen [GWh]','FontName',Fontname,'Fontsize',Fontsize) ylabel('Kosten/Erlöse Mio. €/a','FontName',Fontname,'Fontsize',Fontsize) % adding the texts for i=1:size(heights,1) % calculating a position that fits to the relevant bar x=(ranges(i,1)+ranges(i,2))/2; y=heights(i,1); % adding the text (Settint z=1 assuming that this puts it in front of everything) text(x,y,1,sprintf(texts{i}),'FontName',Fontname,'Fontsize',Fontsize,'backgroundcolor',[1 1 1],'edgecolor',[0 0 0],'interpreter','none') end % printing the figure print(gcf,'test.png','-dpng','-r300')
|
Pages: 1 Prev: Neural Network Toolbox Next: ps resultion switch, -r###, makes print disregard all fontsizes |