plot2svg
plot2svg copied to clipboard
Scaling factors of exponentially scaled ticks not visible [possible solution included]
Using Matlab 2013b.
Scaling factors of exponentially scaled ticks are not printed in the current version.
figure;plot([1 2],[0.00001 0.00002]);
plot2svg;
This is caused by a NaN
-result of the call str2double(numlabels)
. However, a small fix in the function exponent2svg
can solve the issue: Replacing
if ~isempty(numlabels)
numlabels = str2double(numlabels);
end
with
if ~isempty(numlabels)
numlabels_tmp = str2double(numlabels);
if(isnan(numlabels_tmp)) || size(numlabels,1) ~= size(numlabels_tmp,1)
numlabels = str2num(numlabels);
else
numlabels = numlabels_tmp;
end
end
tree times (for XTickLabel
, YTickLabel
and ZTickLabel
) produces a correct figure. Maybe numlabels = str2double(numlabels);
can simply be replaced by numlabels = str2num(numlabels);
but I don't know the benefits of str2double
and before breaking other things (e.g. in newer Matlab versions), the solution provided above should be safe.
A second bug in the same function exponent2svg
causes scaling factors of ticks including a zero not to be plotted:
figure;plot([1 2],[-0.00001 0.00001]);
plot2svg;
Solve this bug for example by replacing
if (length(indexnz) == length(numlabels) && max(indexnz) <= length(numlabels))
ratio = numlabels(indexnz)./labelpos(indexnz);
else
ratio = 1;
end
with
if (max(indexnz) <= length(numlabels))
ratio = numlabels(labelpos~=0)./labelpos(labelpos~=0);
else
ratio = 1;
end
just wanted to let you know about the first release of fig2svg which should fix this issue:
https://github.com/kupiqu/fig2svg
please give it a try and if the issue is still there please report