Skip to content

Support single point line plots #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plotly/plotly_offline_aux/plotlyoffline.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if plotlyfig.PlotOptions.IncludePlotlyjs
% grab the bundled dependencies
userHome = getuserdir();
plotlyConfigFolder = fullfile(userHome,'.plotly');
plotlyConfigFolder = fullfile(userHome,'.plotly');
plotlyJSFolder = fullfile(plotlyConfigFolder, 'plotlyjs');
bundleName = 'plotly-matlab-offline-bundle.js';
bundleFile = fullfile(plotlyJSFolder, bundleName);
Expand All @@ -30,8 +30,8 @@

% handle plot div specs
id = char(java.util.UUID.randomUUID);
width = [num2str(plotlyfig.layout.width) 'px'];
height = [num2str(plotlyfig.layout.height) 'px'];
width = plotlyfig.layout.width + "px";
height = plotlyfig.layout.height + "px";

if plotlyfig.PlotOptions.ShowLinkText
linkText = plotlyfig.PlotOptions.LinkText;
Expand Down
53 changes: 13 additions & 40 deletions plotly/plotlyfig_aux/core/updateAxis.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,41 +69,26 @@

%---------------------------------------------------------------------%

%-xaxis-%
if isHeatmapAxis
xaxis = extractHeatmapAxisData(obj,axisData, 'X');
xExponentFormat = 0;
else
[xaxis, xExponentFormat] = extractAxisData(obj,axisData, 'X');
end

%---------------------------------------------------------------------%

%-yaxis-%
if isHeatmapAxis
yaxis = extractHeatmapAxisData(obj,axisData, 'Y');
yExponentFormat = 0;
else
[yaxis, yExponentFormat] = extractAxisData(obj,axisData, 'Y');
end

%---------------------------------------------------------------------%

%-get position data-%
axisPos = axisData.Position .* obj.PlotOptions.DomainFactor;
if obj.PlotOptions.AxisEqual
axisPos(3:4) = min(axisPos(3:4));
end

%---------------------------------------------------------------------%

%-xaxis domain-%
xaxis.domain = min([axisPos(1) sum(axisPos([1,3]))], 1);
scene.domain.x = xaxis.domain;

%---------------------------------------------------------------------%

%-yaxis domain-%
yaxis.domain = min([axisPos(2) sum(axisPos([2,4]))], 1);
scene.domain.y = yaxis.domain;

Expand All @@ -122,8 +107,8 @@
exponentText = sprintf('x10^%d', yExponentFormat);

obj.layout.annotations{anIndex}.text = exponentText;
obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)];
obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)];
obj.layout.annotations{anIndex}.xref = "x" + xsource;
obj.layout.annotations{anIndex}.yref = "y" + ysource;
obj.layout.annotations{anIndex}.xanchor = 'left';
obj.layout.annotations{anIndex}.yanchor = 'bottom';
obj.layout.annotations{anIndex}.font.size = yaxis.tickfont.size;
Expand All @@ -142,8 +127,8 @@
exponentText = sprintf('x10^%d', xExponentFormat);

obj.layout.annotations{anIndex}.text = exponentText;
obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)];
obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)];
obj.layout.annotations{anIndex}.xref = "x" + xsource;
obj.layout.annotations{anIndex}.yref = "y" + ysource;
obj.layout.annotations{anIndex}.xanchor = 'left';
obj.layout.annotations{anIndex}.yanchor = 'bottom';
obj.layout.annotations{anIndex}.font.size = xaxis.tickfont.size;
Expand All @@ -159,50 +144,38 @@

%---------------------------------------------------------------------%

%-xaxis anchor-%
xaxis.anchor = ['y' num2str(ysource)];

%---------------------------------------------------------------------%
xaxis.anchor = "y" + ysource;
yaxis.anchor = "x" + xsource;

%-yaxis anchor-%
yaxis.anchor = ['x' num2str(xsource)];

%---------------------------------------------------------------------%

%-xaxis overlaying-%
if xoverlay
xaxis.overlaying = ['x' num2str(xoverlay)];
xaxis.overlaying = "x" + xoverlay;
end

%---------------------------------------------------------------------%

%-yaxis overlaying-%
if yoverlay
yaxis.overlaying = ['y' num2str(yoverlay)];
yaxis.overlaying = "y" + yoverlay;
end

%---------------------------------------------------------------------%

% update the layout field (do not overwrite source)
if xsource == axIndex
obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis);
obj.layout = setfield(obj.layout,['scene' num2str(xsource)],scene);
obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis);
obj.layout = setfield(obj.layout, "scene" + xsource, scene);
end

%---------------------------------------------------------------------%

% update the layout field (do not overwrite source)
if ysource == axIndex
obj.layout = setfield(obj.layout,['yaxis' num2str(ysource)],yaxis);
obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis);
end

%---------------------------------------------------------------------%

%-REVERT UNITS-%
set(obj.State.Axis(axIndex).Handle,'Units',axisUnits);
set(obj.State.Axis(axIndex).Handle, 'Units', axisUnits);

try
set(obj.State.Axis(axIndex).Handle,'FontUnits',fontUnits);
set(obj.State.Axis(axIndex).Handle, 'FontUnits', fontUnits);
catch
% TODO
end
Expand Down
40 changes: 8 additions & 32 deletions plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@

%---------------------------------------------------------------------%

%-xaxis-%
xaxis = extractAxisData(obj,axisData, 'X');

%---------------------------------------------------------------------%

%-yaxis-%
[yaxis, yAxisLim] = extractAxisDataMultipleYAxes(obj, axisData, yaxIndex);

%---------------------------------------------------------------------%
Expand All @@ -42,13 +37,8 @@

%---------------------------------------------------------------------%

%-xaxis domain-%
xaxis.domain = min([xo xo + w],1);
scene.domain.x = min([xo xo + w],1);

%---------------------------------------------------------------------%

%-yaxis domain-%
yaxis.domain = min([yo yo + h],1);
scene.domain.y = min([yo yo + h],1);

Expand All @@ -58,39 +48,27 @@

%---------------------------------------------------------------------%

%-xaxis anchor-%
xaxis.anchor = ['y' num2str(ysource)];

%---------------------------------------------------------------------%
xaxis.anchor = "y" + ysource;
yaxis.anchor = "x" + xsource;

%-yaxis anchor-%
yaxis.anchor = ['x' num2str(xsource)];

%---------------------------------------------------------------------%

%-xaxis overlaying-%
if xoverlay
xaxis.overlaying = ['x' num2str(xoverlay)];
xaxis.overlaying = "x" + xoverlay;
end

%---------------------------------------------------------------------%

%-yaxis overlaying-%
if yoverlay
yaxis.overlaying = ['y' num2str(yoverlay)];
yaxis.overlaying = "y" + yoverlay;
end

%---------------------------------------------------------------------%

% update the layout field (do not overwrite source)
if xsource == axIndex
obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis);
obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis);
end

%---------------------------------------------------------------------%

% update the layout field (do not overwrite source)
obj.layout = setfield(obj.layout,['yaxis' num2str(ysource)],yaxis);
obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis);

%---------------------------------------------------------------------%

Expand All @@ -110,8 +88,6 @@
plotIndex = obj.PlotOptions.nPlots;

obj.data{plotIndex}.type = 'scatter';
obj.data{plotIndex}.xaxis = ['x' num2str(xsource)];
obj.data{plotIndex}.yaxis = ['y' num2str(ysource)];

%---------------------------------------------------------------------%
obj.data{plotIndex}.xaxis = "x" + xsource;
obj.data{plotIndex}.yaxis = "y" + ysource;
end
18 changes: 2 additions & 16 deletions plotly/plotlyfig_aux/core/updateConstantLine.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,14 @@ function updateConstantLine(obj,plotIndex)

%---------------------------------------------------------------------%

%-scatter xaxis-%
obj.data{plotIndex}.xaxis = ["x" num2str(xsource)];

%---------------------------------------------------------------------%

%-scatter yaxis-%
obj.data{plotIndex}.yaxis = ["y" num2str(ysource)];

%---------------------------------------------------------------------%

%-scatter type-%
obj.data{plotIndex}.xaxis = "x" + xsource;
obj.data{plotIndex}.yaxis = "y" + ysource;
obj.data{plotIndex}.type = "scatter";

%---------------------------------------------------------------------%

%-scatter visible-%
obj.data{plotIndex}.visible = strcmp(plotData.Visible, "on");

%---------------------------------------------------------------------%

%-scatter-%

xaxis = obj.layout.("xaxis"+xsource);
yaxis = obj.layout.("yaxis"+ysource);
value = [plotData.Value plotData.Value];
Expand Down
Loading