Skip to content

fixing issues related to tick-values-labels and colorbar #404

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
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
5 changes: 2 additions & 3 deletions plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
end

%-PlotlyDefaults-%
obj.PlotlyDefaults.MinTitleMargin = 80;
obj.PlotlyDefaults.MinTitleMargin = 10;
obj.PlotlyDefaults.TitleHeight = 0.01;
obj.PlotlyDefaults.TitleFontSizeIncrease = 40;
obj.PlotlyDefaults.FigureIncreaseFactor = 1.5;
Expand Down Expand Up @@ -788,7 +788,6 @@ function validate(obj)
end
catch
% TODO to the future
% disp('catch at line 679 in plotlyfig.m file')
end
end

Expand Down Expand Up @@ -1108,7 +1107,7 @@ function delete(obj)
|| strcmpi(fieldname,'legend') || strcmpi(fieldname,'histogram')...
|| strcmpi(fieldname,'scatter') || strcmpi(fieldname,'line')...
|| strcmpi(fieldname,'scattergeo') || strcmpi(fieldname,'scattermapbox')...
|| strcmpi(fieldname,'scatterternary')...
|| strcmpi(fieldname,'scatterternary') || strcmpi(fieldname,'colorbar')...
)
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
end
Expand Down
87 changes: 65 additions & 22 deletions plotly/plotlyfig_aux/core/updateAxis.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,60 +42,61 @@
% position:...[NOT SUPPORTED IN MATLAB]

%-STANDARDIZE UNITS-%
axisunits = get(obj.State.Axis(axIndex).Handle,'Units');
axisUnits = get(obj.State.Axis(axIndex).Handle,'Units');
set(obj.State.Axis(axIndex).Handle,'Units','normalized')

try
fontunits = get(obj.State.Axis(axIndex).Handle,'FontUnits');
fontUnits = get(obj.State.Axis(axIndex).Handle,'FontUnits');
set(obj.State.Axis(axIndex).Handle,'FontUnits','points')
catch
% TODO
end

%-AXIS DATA STRUCTURE-%
axis_data = get(obj.State.Axis(axIndex).Handle);
axisData = get(obj.State.Axis(axIndex).Handle);

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

%-check if headmap axis-%
is_headmap_axis = isfield(axis_data, 'XDisplayData');
is_headmap_axis = isfield(axisData, 'XDisplayData');
obj.PlotOptions.is_headmap_axis = is_headmap_axis;

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

%-check if geo-axis-%
isGeoaxis = isfield(axis_data, 'Type') && strcmpi(axis_data.Type, 'geoaxes');
isGeoaxis = isfield(axisData, 'Type') && strcmpi(axisData.Type, 'geoaxes');
obj.PlotlyDefaults.isGeoaxis = isGeoaxis;

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

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

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

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

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

%-getting and setting postion data-%

xo = axis_data.Position(1);
yo = axis_data.Position(2);
w = axis_data.Position(3);
h = axis_data.Position(4);
xo = axisData.Position(1);
yo = axisData.Position(2);
w = axisData.Position(3);
h = axisData.Position(4);

if obj.PlotOptions.AxisEqual
wh = min(axis_data.Position(3:4));
wh = min(axisData.Position(3:4));
w = wh;
h = wh;
end
Expand All @@ -114,10 +115,56 @@

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

%-get source axis-%
[xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj,axIndex);

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

%-set exponent format-%
anIndex = obj.State.Figure.NumTexts;

if yExponentFormat ~= 0
anIndex = anIndex + 1;
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}.xanchor = 'left';
obj.layout.annotations{anIndex}.yanchor = 'bottom';
obj.layout.annotations{anIndex}.font.size = yaxis.tickfont.size;
obj.layout.annotations{anIndex}.font.color = yaxis.tickfont.color;
obj.layout.annotations{anIndex}.font.family = yaxis.tickfont.family;
obj.layout.annotations{anIndex}.showarrow = false;

if isfield(xaxis, 'range') && isfield(yaxis, 'range')
obj.layout.annotations{anIndex}.x = min(xaxis.range);
obj.layout.annotations{anIndex}.y = max(yaxis.range);
end
end

if xExponentFormat ~= 0
anIndex = anIndex + 1;
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}.xanchor = 'left';
obj.layout.annotations{anIndex}.yanchor = 'bottom';
obj.layout.annotations{anIndex}.font.size = xaxis.tickfont.size;
obj.layout.annotations{anIndex}.font.color = xaxis.tickfont.color;
obj.layout.annotations{anIndex}.font.family = xaxis.tickfont.family;
obj.layout.annotations{anIndex}.showarrow = false;

if isfield(xaxis, 'range') && isfield(yaxis, 'range')
obj.layout.annotations{anIndex}.x = max(xaxis.range);
obj.layout.annotations{anIndex}.y = min(yaxis.range);
end
end

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

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

Expand Down Expand Up @@ -145,27 +192,23 @@
% 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);
else

obj.layout = setfield(obj.layout,['scene' num2str(xsource)],scene);
end

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

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

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
Loading