"TiledChartLayout cannot be a parent." error message using pdeplot with tiledlayout

6 次查看(过去 30 天)
I want to plot multiple solutions obtained with the PDE Modeling next to each other. Using subplot works just fine, but I want to use the more flexible tiledlayout command. However, this gives the error message "Error using uicontextmenu; TiledChartLayout cannot be a parent". Here's a MWA (the first few lines are just to have a solution to a PDE problem):
clear; close all
model = createpde;
geometryFromEdges(model,@lshapeg);
generateMesh(model);
applyBoundaryCondition(model,"dirichlet",Edge=1:model.Geometry.NumEdges,u=0);
specifyCoefficients(model,m=0, d=0, c=1, a=0, f=1);
results = solvepde(model);
% this works fine
subplot(1,2,1);
pdeplot(model,"XYData",results.NodalSolution);
subplot(1,2,2);
pdeplot(model,"XYData",results.NodalSolution);
% this one doesn't
figure;
tiledlayout(1,2);
nexttile;
pdeplot(model,"XYData",results.NodalSolution);
Error using uicontextmenu
TiledChartLayout cannot be a parent.

Error in pdeplot (line 1185)
hc=colorbar(ax,'UIContextMenu',uicontextmenu(ax.Parent)); % Disable context menu
nexttile;
pdeplot(model,"XYData",results.NodalSolution);
Any tips how to solve the issue?
  2 个评论
Matt J
Matt J 2023-10-5
编辑:Matt J 2023-10-5
I don't think there is a solution that would allow you to use tiledlayout. It would be helpful to know what tiledlayout functionality you are looking to use which you think subplot doesn't offer. There are many File Exchange tools designed to give similar functionality as tiledlayout, but using only the subplot framework.
Nicolas Schlosser
Nicolas Schlosser 2023-10-5
编辑:Nicolas Schlosser 2023-10-5
I guess I could use one of these workarounds. I wanted to reuse code from another project where tiledlayout worked as intended in order to create a common title and axes for the whole plot, like here: https://de.mathworks.com/matlabcentral/answers/499823-one-common-xlabel-and-ylabel-for-multiple-subplots . Also, I wanted to reduce the margins and make the whole image more compact. And since Matlab explicitly recommends using tiledlayout over subplot (as seen in the documentation of tiledlayout at https://de.mathworks.com/help/matlab/ref/tiledlayout.html ), I figured the two could be used interchangeably, or at least that subplot can in all cases be substituted with tiledlayout.

请先登录,再进行评论。

回答(1 个)

Matt J
Matt J 2023-10-5
编辑:Matt J 2023-10-5

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by