Skip to content

Commit

Permalink
Merge pull request #602 from okomarov/fixStairsAndAreaLegend
Browse files Browse the repository at this point in the history
Fix stairs and area legend
  • Loading branch information
Oleg Komarov committed Apr 8, 2015
2 parents 3330e4f + 52b6f7b commit 1035a51
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
19 changes: 13 additions & 6 deletions src/matlab2tikz.m
Expand Up @@ -3454,11 +3454,11 @@ case size(cData,2) % specific y-data is given
lineWidth = get(h, 'LineWidth');
marker = get(h, 'Marker');

if ((isNone(lineStyle) || lineWidth==0) && isNone(marker))
if (isNone(lineStyle) || lineWidth==0) && isNone(marker)
return % nothing to plot!
end

%% deal with draw options
% deal with draw options
color = get(h, 'Color');
[m2t, plotColor] = getColor(m2t, h, color, 'patch');

Expand All @@ -3470,10 +3470,13 @@ case size(cData,2) % specific y-data is given
drawOptions = opts_add(drawOptions, 'color', plotColor);
drawOptions = opts_merge(drawOptions, lineOptions, markerOptions);

%% insert draw options
drawOpts = opts_print(m2t, drawOptions, ',');
% Toggle legend entry
drawOptions = maybeShowInLegend(m2t.currentHandleHasLegend, drawOptions);

% insert draw options
drawOpts = opts_print(m2t, drawOptions, ',');

%% plot the thing
% plot the thing
xData = get(h, 'XData');
yData = get(h, 'YData');
[m2t, table, tabOpts] = makeTable(m2t, '', xData, '', yData);
Expand Down Expand Up @@ -3523,6 +3526,10 @@ case size(cData,2) % specific y-data is given
else
drawOptions = opts_add(drawOptions, 'draw', xEdgeColor);
end

% Toggle legend entry
drawOptions = maybeShowInLegend(m2t.currentHandleHasLegend, drawOptions);

drawOpts = opts_print(m2t, drawOptions, ',');

% plot the thing
Expand Down Expand Up @@ -3766,7 +3773,7 @@ case size(cData,2) % specific y-data is given

filling = get(handle, 'FaceColor');

%% Has a filling?
% Has a filling?
if isNone(filling)
drawOptions = opts_add(drawOptions, xcolor);
drawCommand = '\draw';
Expand Down
4 changes: 2 additions & 2 deletions test/suites/ACID.MATLAB.8.3.md5
Expand Up @@ -4,7 +4,7 @@ annotationAll : 3f34845acba1235af1f62b9edab9769d
annotationSubplots : 5f26cd035c0224e873f9b6c669f86192
annotationText : 980a64a699884fba7074f9c382261148
annotationTextUnits : d7550c262ed62bceeea4a43df1083944
areaPlot : 1ecaafedecb1ef68bfa779b2df488160
areaPlot : 3f7ec4623a5131deb5251f99208858e7
axesColors : 7fc79e2c9debab7d479070eaa8ce6268
axesLocation : d2f2902fb3d926e6d82a8c6f71cb50bc
bars : 0f7af6b42225e822c343514a3c71b62f
Expand Down Expand Up @@ -78,7 +78,7 @@ sine_with_markers : 2acd2ab1102055821993449abca3ead1
spectro : 25abf6318aa26766ee353a8a439bb6e1
spherePlot : d1b850f86615c63588afabd25b6aa98d
stackedBarsWithOther : 415e5a8a12881c0660ad5346020b9ec4
stairsplot : f86135875ecac7deb1d1146c2bb773b8
stairsplot : aab9adf136000e9150a32b11e55189b2
stemplot : 9a612d5786ffbac078b192e70d50b93d
stemplot2 : a2c48084047a3a5d7f904c1623730d15
subplot2x2b : 822aee5e3a1bc583a97c4a4cbbb1eeab
Expand Down
4 changes: 2 additions & 2 deletions test/suites/ACID.MATLAB.8.4.md5
Expand Up @@ -4,7 +4,7 @@ annotationAll : 38e1f845b613f5e1b616df2d8e7fdc72
annotationSubplots : 7f2b6c865ef1db561faed58714babbc2
annotationText : 7d84c8fe322ac47f304f44f2c94db3e1
annotationTextUnits : 21b9d79658c1afc18b0a7ad64836143e
areaPlot : 2dd1a3abd3276f64cc62e3e35119b580
areaPlot : eac896ed3c483be2747cf1432fb5879e
axesColors : 07bba31089e5d3a41b4c188517b502c9
axesLocation : f519f61ef3045d088e2ae0107273985e
bars : e95705931907e154cc58f9ee2766850c
Expand Down Expand Up @@ -78,7 +78,7 @@ sine_with_markers : c7395ad70f98cec64c307e89392467cc
spectro : aceff5ac5c6c49079a6fa80f2ea2483a
spherePlot : b185d8d77ac586f84648a220d95df5ec
stackedBarsWithOther : 4b40c7f871c204e02744e7dbf670e7f0
stairsplot : 85aa9e5aebaca180a2d4f0ea69af8f41
stairsplot : af0a4693e85345bd1fe3e8f3d1e37882
stemplot : 7df754dc7dd381c105158054a9719a57
stemplot2 : 2d8c2c0ad363b6dfdde2b63fbe810440
subplot2x2b : af7dabaa6c7cc1c3bb8c29d76cc66ae3
Expand Down
4 changes: 2 additions & 2 deletions test/suites/ACID.Octave.3.8.0.md5
@@ -1,6 +1,6 @@
alphaImage : f6a2e2d1756f72cbad060d0a85116134
alphaTest : 9d458c612443b2057184427c91bdd5ce
areaPlot : 9b367779566f4bc7605a6f7b8483e34d
areaPlot : 72a4df5efbd80d355dd7558521d9636f
axesColors : cc0a6def293580e4f51790dfb477d632
axesLocation : 5ba110beaee8adc0f969effd8ab68e4b
bars : fee1a09f11d4dfe717e7ff955fe6f709
Expand Down Expand Up @@ -59,7 +59,7 @@ sine_with_annotation : e5c5e6af1965d21556c589a4ceb73096
sine_with_markers : 60a205fbfb299cf86891afb1751ba18b
spherePlot : e1430fbae3687d38b092c5ed8d080283
stackedBarsWithOther : 5234f0a0466c3b41bdf20f5c787b73ac
stairsplot : a7051c3615d71f48468ad5253800f744
stairsplot : f06b194a550ce5e7836c7a882bb1f65b
stemplot : d5a5d808c1471b4b10f671d8dfb07d61
stemplot2 : 9f819acf72671be9d8cc280d3fffa065
subplot2x2b : a16dc07d101a4b50dcd18232cfdb802a
Expand Down
9 changes: 5 additions & 4 deletions test/suites/ACID.m
Expand Up @@ -648,8 +648,9 @@
function [stat] = stairsplot()
stat.description = 'A simple stairs plot.' ;

x = linspace(-2*pi,2*pi,40);
stairs(x,sin(x))
x = linspace(-2*pi,2*pi,40)';
h = stairs([sin(x), 0.2*cos(x)]);
legend(h(2),'second entry')
end
% =========================================================================
function [stat] = quiverplot()
Expand Down Expand Up @@ -1882,8 +1883,8 @@

M = magic(5);
M = M(1:3,2:4);
area(1:3, M);
legend('foo', 'bar', 'foobar');
h = area(1:3, M);
legend(h([1,3]),'foo', 'foobar');
end
% =========================================================================
function [stat] = customLegend()
Expand Down

0 comments on commit 1035a51

Please sign in to comment.