Search Comments and Ratings

go

   
Date File Comment by Comment Rating
24 Feb 2015 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Durga Lal Shrestha

It is pity that plot2svg does not support legend in MATLAB R2014b.

Comment only
30 Nov 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Juerg Schwizer

Juerg Schwizer (view profile)

To all Matlab R2014b users:

As the graphic engine of Matlab R2014b contains major changes some functionality is no more compatible. The svg format is finally supported natively. Unfortunately, the resulting files are sometimes very big. The latest version of plot2svg can be found on git

https://github.com/jschwizer99/plot2svg

The current version available contains first changes needed for Matlab R2014b support. Please also report bugs there.

Comment only
27 Nov 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Valentin

Dear Juerg, thanks for this great contribution. Are you still interested in bug fixes?

If the axes are in log scale, only the minor grids lower than the biggest tick are plotted. However, if you want to continue the minor grid, you can replace

axxtick = log10(get(ax,'XTick'));
minor_axxtick = [];
if ~isempty(axxtick_w)
all_axxtick = axxtick(1):1:axxtick(end);
for stick = all_axxtick
minor_axxtick = [minor_axxtick minor_log_sticks + stick];
end
end
minor_axxtick = minor_axxtick(find(minor_axxtick > min(axlimx) & minor_axxtick < max(axlimx)));

around line 940 with

axxtick = log10(get(ax,'XTick'));
minor_axxtick = [];
%if ~isempty(axxtick_w)
%all_axxtick = axxtick(1):1:axxtick(end);
all_axxtick = ceil(min(axlimx)):1:ceil(max(axlimx));
for stick = all_axxtick
minor_axxtick = [minor_axxtick minor_log_sticks + stick];
end
%end
minor_axxtick = minor_axxtick(find(minor_axxtick > min(axlimx) & minor_axxtick < max(axlimx)));

(and for the y and z axis respectively). I personally consider this as a bug, but maybe this original behavior was intended.

Comment only
25 Nov 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

NGUYEN

NGUYEN (view profile)

Dear Juerg,
First, i would like to thank you for sharing a great tool.

I have the following problem with a figure of dimension 3 could you help me to fix it please!

Subscript indices must either be real positive integers or logicals.

Error in plot2svg>axchild2svg (line 1481)
[z,face_index]=sort(sum(z(faces(:,:)),2));

Error in plot2svg>axes2svg (line 1062)
group = axchild2svg(fid,id,axIdString,ax,group,paperpos,axchild,axpos,groupax,projection,boundingBoxAxes);

Error in plot2svg (line 243)
group=axes2svg(fid,id,ax(j),group,paperpos);

Thanks a lot

4
17 Nov 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Rodolphe

Same as Richard, i have the "Warning: Unhandled main figure child type". If anybody has a fix...

5
11 Nov 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Neil Dalchau

This is a brilliant contribution. Thank you!

I have found a bug with reproducing textbox annotations. The left-hand edge is not reproduced. A simple example is:

annotation('textbox',[0.2 0.3 0.6 0.4],'String','test')
plot2svg('test.svg')

5
08 Nov 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Bauyrzhan Aubakir

Can I suggest Adding support of svg(html) links?

5
24 Oct 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Richard

Hi All

I have an issue getting plot2svg working on matlab 2014b, whereas it worked perfectly before.

Initially I had the some problem as Mirko, but I was able to fix it using the comments below. I now get the following errors:

Warning: Unhandled child type: contour
Warning: Unhandled main figure child type: colorbar

The code produces an svg file but the axes are empty and there is no colorbar.

Richard

Comment only
14 Oct 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Mirko

Mirko (view profile)

Sorry, my fault, I fixed the error thanks to Jeff suggestion.

Comment only
14 Oct 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Mirko

Mirko (view profile)

I'm using this function since long time ago, but now I upgrated matlab to R2014b version and it isn't working anymore!

I get this msg error:

Error using str2num (line 32)
Requires string or character array input.

Error in plot2svg>exponent2svg (line 2429)
numlabels =
str2num(get(ax,'XTickLabel'));

Error in plot2svg>axes2svg (line 1321)
exponent2svg(fid,groupax,axpos,paperpos,ax,axxtick,axytick,axztick)

Error in plot2svg (line 243)
group=axes2svg(fid,id,ax(j),group,paperpos);

Comment only
29 Jul 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Darik

Darik (view profile)

5
24 Jul 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Jeff

Jeff (view profile)

Evidently str2num used to work on cell arrays? To get it to work I had to change line 2451 from
numlabels(ix) = str2num(axlabely{ix});
to
numlabels(ix) = str2double(axlabely{ix});

Otherwise, it does just what I need, thanks!

5
19 Jun 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Ehsan

Ehsan (view profile)

One of my favorites. Thank you

5
10 Jun 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

xiaomi

xiaomi (view profile)

I tried your code, and it works for me.

text(1 ,0.5,0,'{\bf TEST}','Interpreter','latex','Rotation',90);

Comment only
10 Jun 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Durga Lal Shrestha

It seems the plot2svg does not support bold font for label and texts. It is said in description of the script that Latex commands are interpreted (with some limitations). I tried
text(1 ,0.5,0,'{\bf TEST}','Interpreter','latex','Rotation',90);

But it does not produce bold font. Is there any solution to produce bold font?

Comment only
27 May 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Alessandro Masullo

I really love this script but I have to report a bug dealing with squared scatter plot.

It can be easly reproduced by:

scatter(rand(1,10),rand(1,10),30,rand(1,10),'s','filled')
plot2svg('test.svg')

it yields this error:

Undefined function or variable "linex".

Error in plot2svg>axchild2svg (line 1630)
case {'square', 's'},group=group+1;patch2svg(fid,group,axpos,xmarker'*ones(1,5)+ones(length(linex),1)*[-1 -1 1 1
-1]*markersize,ymarker'*ones(1,5)+ones(length(liney),1)*[-1 1

5
07 Apr 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Natan

Natan (view profile)

Is there an easy way to use this function for figures where the colormap has more than 256 colors?

Comment only
26 Mar 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Sinan Teske

If I rotate the view of a 3D-Plot with view(5,10) for example, the TickMarks and the TickLabels are wrong in length and positioning, respectively.

Would be nice if a fix for that could be provided. ZLabelTick should maybe always point horizontally or sizing should be view dependend.

Also marks at the corners of the were clipped so I had to enlarge the bounding Box of the axes by changing line 759
% boundingBoxAxes = [min(x) min(y) max(x)-min(x) max(y)-min(y)];

to

boundingBoxAxes = [min(x)-0.1*min(x) min(y)-0.1*min(y) max(x)+0.1*max(x)-min(x) max(y)+0.1*max(y)-min(y)];

Additionally in the adchild2svg function
under line
elseif strcmp(get(axchild(i),'Type'),'patch')

I had to add
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
linex = get(axchild(i),'XData');
liney = get(axchild(i),'YData');
linez = get(axchild(i),'ZData');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

to support other marker types such as diamonds of scatter3 generated markers.

But thanks for this great Tool!!

4
11 Mar 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Adam Andersen Læssøe

This works really well.
It's a mystery to me, though, why you scale circle-markers to 0.75 of MarkerSize. It makes plots with different marker-types less coherent.

Easily 'fix'able, though: In plot2svg.m, L.1409, replace 0.75 with 1.

5
26 Feb 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Pulkit Budhiraja

5
24 Feb 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Giorgio

I was looking for something like this for weeks

5
13 Jan 2014 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Sebastian Hölz

I experienced some problems when exporting a figure with a map containing a true color image. Upon export the "linked" image was plain empty. I could track this down to line 2024 of the code "imwrite(pointc, ..."

pointc is changed to double (n x m x 3) a few lines above. If you cast it back to uint8, the imwrite command works as expected (i.e. "imwrite(uint8(pointc), ..."

I don't know if this is a case in plot2svg, which is just not handled or maybe if the imwrite command has changed.

Comment only
18 Dec 2013 plot2mif Vector graphics export of 2D MATLAB plots to Framemaker MIF-files. Author: Juerg Schwizer

Juerg Schwizer (view profile)

Elnaz

Elnaz (view profile)

Does anybody know why the minor ticks on the "y" axis for example are not converted into the .mif file?

Comment only
26 Oct 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

ejs

ejs (view profile)

Hi ANI,

you should learn Matlab:
plot2svg([fileName '.svg']);

Comment only
24 Oct 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Richi

Richi (view profile)

This has saved me days in exporting MATLAB figures!

5
03 Oct 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

ANI

ANI (view profile)

I have many ".fig" files in a folder (say one.fig, two.fig ...etc). I want to convert all of them into ".svg" files (say one.svg, two.svg ...etc) using "plot2svg". I came up with this script:

function myfun = test
dirListing = dir('*.fig');
for d = 1:length(dirListing)
fileName = dirListing(d).name;
openfig(fileName);
plot2svg('fileName.svg');
end

This will open all ".fig" files in the folder, but save all the figures with the same file name i.e. "fileName.svg". This is because "plot2svg" takes the "fileName" literally instead of taking the dynamic BASE name (without extension, a bonus) of the file from "fileName = dirListing(d).name;".

What is the workaround? How to make "plot2svg" take dynamic base name of the files?

Comment only
18 Sep 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

ejs

ejs (view profile)

Hi All,

i've also got a kickout at line 1630 with:

Matlab/Octave to SVG converter version 15-Sep-2012, Juerg Schwizer (converter@bluewin.ch).
Undefined function or variable "linex".

Error in plot2svg>axchild2svg (line 1630)
case {'square',
's'},group=group+1;patch2svg(fid,group,axpos,xmarker'*ones(1,5)+ones(length(linex),1)*[-1
-1 1 1 -1]*markersize,ymarker'*ones(1,5)+ones(length(liney),1)*[-1 1
Error in plot2svg>axchild2svg (line 2075)
group=axchild2svg(fid,id,axIdString,ax,group,paperpos,get(axchild(i),
'Children'),axpos,groupax,projection,boundingBoxAxes);

Error in plot2svg>axes2svg (line 1062)
group =
axchild2svg(fid,id,axIdString,ax,group,paperpos,axchild,axpos,groupax,projection,boundingBoxAxes);

Error in plot2svg (line 243)
group=axes2svg(fid,id,ax(j),group,paperpos);

I was exporting scatter plots to SVG.

The patch is to add the lines just after the line 1462:

% edited by ejs, 2013-09-18
linex = get(axchild(i),'XData');
% Octave stores the data in a column vector
linex = linex(:)';
if strcmp(get(ax,'XScale'),'log')
linex(find(linex<=0)) = NaN;
linex=log10(linex);
end

liney=get(axchild(i),'YData');
% Octave stores the data in a column vector
liney = liney(:)';
if strcmp(get(ax,'YScale'),'log')
liney(find(liney<=0)) = NaN;
liney=log10(liney);
end

linez=get(axchild(i),'ZData');
% Octave stores the data in a column vector
linez = linez(:)';
if isempty(linez)
linez = zeros(size(linex));
end
if strcmp(get(ax,'ZScale'),'log')
linez(find(linez<=0)) = NaN;
linez=log10(linez);
end
% end edited by ejs

Hope it will not negatively affect the entire code ;)

5
31 Aug 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Mike

Mike (view profile)

Best function since 'plot();'!
Saves my scientific career. Thank You!

5
28 Aug 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Emmanuel Farhi

An excellent export to a vectorial multi-platform format. Thanks.

5
27 Aug 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Noah Levine-Small

Hey mate. Thanks for submitting such a useful function. :) I think I've found a small bug. Minor tick axes don't appear in the SVG if you are using log scale axes...They do appear in Matlab and if I export to PDF and then import into Inkscape.

Comment only
27 Jul 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Jeroen Oomkes

I tested with this figure and get 'Index exceeds matrix dimensions' error. I fixed this by replacing

for i = 1:length(axxindex)
with:
for i = 1:length(axlabelx)

see: https://dl.dropboxusercontent.com/u/27352353/test.fig

5
02 Jul 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Pearl

Pearl (view profile)

5
25 Jun 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Bharath Lohray

I get SVGs that have the wrong stacking order - The shadows (the countours on the plot floor for a 3d mesh plot) are above the objects instead of below the object.

see: http://img801.imageshack.us/img801/4204/crmm.png
http://pastebin.com/UsmAbSay - The generated svg

5
09 May 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Chuntao Dan

Hi, this seems to be very useful. However, I get an error when there're scattered asterisk in the figure:

Undefined function or variable "linex".

Error in plot2svg>axchild2svg (line 1627)
case '*',group=group+1;patch2svg(fid,group,axpos,xmarker'*ones(1,11)+ones(length(linex),1)*[-1 1 NaN 0 0 NaN -0.7
0.7 NaN -0.7 0.7]*markersize,ymarker'*ones(1,11)+ones(length(

Does anyone know how to fix it? Thanks.

Comment only
11 Apr 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Nam Tran

Hi,
the script works fine.
But sometime i have problem with the ylabel. It is too close the the Y-Axis, and the long label can overlap with the scale. The X-label too.
Does anyone know how to fix it ?

Comment only
08 Apr 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

loich

loich (view profile)

Thank you for this great tool !

However I encounter a problem when I use alpha on image. For exemple with this kind of code:

>> % SVG converter version 15-Sep-2012
>> figure
>> colormap(hsv)
>> image(randi(100,10,10)),
>> alpha(double(rand(10,10)))
>> plot2svg('test.svg',gcf,'png')

In the svg file, the transparency has disapeared.

Is there a way to fix it ?
Thank you

Comment only
01 Apr 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Shuhao Cao

5
21 Mar 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Greg Hale

Thanks Juerg. Any plans to support hgtransform? My hgtransformed' plots in matlab aren't getting moved to the right places.

5
20 Mar 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

avlas

avlas (view profile)

Plot2svg is great. It would be even greater if it could automatically remove these parts of a plot that are masked (e.g. when limiting a plot in a subregion either with axis, xlim or ylim). This would create lighter svg plots and it would fix the problem of import svg files in some applications (e.g. scribus), as some of they take the whole area, including invisible parts, instead of what is the final visible figure. This makes the arrangement of different panels in a composed figure quite difficult.

I hope there is an easy way to do it. I definitely would appreciate it, and I guess other people too.

Thanks for your work!

5
31 Jan 2013 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Dominique

This seems awesome but I'm having a problem with legends. The legend text strays outside of the legend box. Is there an easy fix for that? Try this to see what I mean:

>> figure
>> x = linspace(-pi, pi, 300);
>> plot(x,sin(x));
>> legend('A smooth curve');
>> plot2svg('sin.svg');

Thanks!

Comment only
18 Dec 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Joe

Joe (view profile)

I recently stumbled over this and first of all, I love this package! It is truly brilliant and I especially like the WYSIWYGness of the exported SVGs.

However, this is also what I am having troubles with. I have had absolutely no problems with using plot2svg with ordinary plots. But today, I needed to use it for loglog and semilogx/semilogy plots and it does not work properly - or at least not in my opinion. I like to use "axis square" for my plots, as I like them to be square when I use them in my reports and papers. However, this creates problems when using plot2svg, especially for semilog plots, and the exported figures are squezzed together. Using "axis square" in Matlab yields a square plot, but it can have different scalings on the axes. It appears that when exporting using plot2svg, the scalings are somehow set to be equal instead of the plot dimensions being set to be equal. I would appreciate some help or a nudge in the right direction, as it is quite urgent.

5
25 Oct 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Alan

Alan (view profile)

The code

figure
for ii=1:10
h(ii)=text(0,ii/10,'QWERTYUIOPqwertyuiop1234567890');
set(h(ii),'fontname','courier')
set(h(ii),'fontsize',(ii)+5);
end
print 'testpc.eps' -depsc
plot2svg('test.svg')

produces different results on OS X and Windows.

In both cases, the eps file contains the fonts at the right sizes, i.e. 6,7,8,9,10,11,12,13,14,15 pt

In Windows the font sizes in the svg file are 6,7,8,8,9,10,11,12,13,14 (8 is repeated and every number above 8 is off by 1 point.)

In OS X the font sizes in the svg file are
8,9,10,11,12,14,15,16,18. All way off.

Comment only
24 Oct 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Stuart Layton

Great function! I use it often. I have one suggestion though, the length of the change log makes calling help on the file completely useless. To prevent the change log from showing up during a call to help add a single un-commented empty line between the copyright information and the changelog.

5
23 Oct 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Shuhao Cao

5
10 Sep 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Andrew

Andrew (view profile)

BUGFIX & PATCH

There is a mysterious visible bounding box that shows up in the SVG file.

As an example, run:

figure;
axes
alpha=.2
color=[1 0 0]
hrect=annotation('rectangle',[0.3 0.5 .3 .2])
set(hrect,'FaceColor',color);
set(hrect,'FaceAlpha',alpha);
set(hrect,'LineStyle','none');
plot2svg('test.svg')

Note that the semi-transparent rectangle has no outline on screen, but it does in SVG.

To fix:
At the end of line 1787, immediately following the line:
scolorname=searchcolor(id,get(axchild(i),'EdgeColor'));

INSERT:
linestyle=get(axchild(i),'LineStyle');
if strcmp(linestyle,'none');
scolorname='none';
end

5
07 Aug 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Shuhao Cao

5
24 Jul 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Ben Mitch

Ben Mitch (view profile)

hi Juerg - couple of other comments/questions...

(i) what does the "figuresize" argument do, it doesn't seem to be documented? exported size is controlled as described in "Plots for Scientific Publications", so what could "figuresize" be? am I not finding some documentation, perhaps?

(ii) re. "Plots for Scientific Publications", would it not be more consistent for the export size to be controlled by "PaperPosition"/"PaperUnits" rather than "Position"/"Units", since this is (as I understand it) what these "Paper..." properties are for? the way it is at the moment, the figure has to be updated on screen to affect the export size, which seems unnecessary.

great work :), cheers

5
24 Jul 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Ben Mitch

Ben Mitch (view profile)

hi Juerg. great contribution, thanks :)

"Benjamin" reported a bug in 2009 that appears to be still there. here is how to reproduce it:

figure(1)
plot(randn(100,1));
set(gca, 'ytick', 0:10);
plot2svg

--------

Index exceeds matrix dimensions.

Error in plot2svg>exponent2svg (line 2434)
ratio = numlabels(indexnz)./labelpos(indexnz);

Comment only
16 Jul 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

Philippe

I had a problem with exporting a figure:

Subscript indices must either be real positive integers or logicals.

Error in plot2svg>axchild2svg (line 1570)
patch2svg(fid, group, axpos, x(faces_nonan), y(faces_nonan),
facecolorname, linestyle, linewidth, edgecolorname, face_opacity,
edge_opacity, closed)

After investigation, the error is caused by patches with NaN faces. Removing NaN elements from the faces array fixed the problem. Here is the modification around line 1566:

faces_nonan = faces(p,:);
faces_nonan = faces_nonan(isfinite(faces_nonan));

if flat_shading
patch2svg(fid, group, axpos, x(faces_nonan), y(faces_nonan), facecolorname, linestyle, linewidth, edgecolorname, face_opacity, edge_opacity, closed)
else
gouraud_patch2svg(fid, group, axpos, x(faces_nonan), y(faces_nonan), cdata, linestyle, linewidth, edgecolorname, face_opacity, edge_opacity, id)
end

Thank you for this great library!

Comment only
04 Jul 2012 Scalable Vector Graphics (SVG) Export of Figures Converts 3D and 2D MATLAB plots to the scalable vector format (SVG). Author: Juerg Schwizer

Juerg Schwizer (view profile)

avlas

avlas (view profile)

Hi,

plot2svg is just great.

FYI, I think there is a bug when using scatter3 with different colors, as result from plot2svg appears with a single color.

Hope this can be fixed...

5

Contact us