-
Notifications
You must be signed in to change notification settings - Fork 98
Subplots with individual titles #387
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
Comments
The To set titles for individual subplots, you have to use However, I ended up with this code, which is a bit awkward but should be a good workaround for now (ideally, you would create the annotations with positional logic in some kind of function beforehand instead of manually): using Plotly.NET;
using Plotly.NET.LayoutObjects;
using Plotly.NET.CSharp;
Plotly.NET.CSharp.Chart.Grid(
new [] {
Plotly.NET.CSharp.Chart.Point<int,int,string>(x: new [] { 1 }, y: new [] { 1 }),
Plotly.NET.CSharp.Chart.Point<int,int,string>(x: new [] { 1 }, y: new [] { 1 }),
Plotly.NET.CSharp.Chart.Point<int,int,string>(x: new [] { 1 }, y: new [] { 1 }),
Plotly.NET.CSharp.Chart.Point<int,int,string>(x: new [] { 1 }, y: new [] { 1 })
},
2,
2
).WithAnnotations(
new Annotation [] {
Annotation.init<double,double,string,string,string,string,string,string,string,string>(
X: 0.225,
Y : 1,
XAnchor: StyleParam.XAnchorPosition.Center,
ShowArrow : false,
YAnchor : StyleParam.YAnchorPosition.Bottom,
Text : "plot1",
XRef : "paper",
YRef : "paper"
),
Annotation.init<double,double,string,string,string,string,string,string,string,string>(
X: 0.775,
Y : 1,
XAnchor: StyleParam.XAnchorPosition.Center,
ShowArrow : false,
YAnchor : StyleParam.YAnchorPosition.Bottom,
Text : "plot2",
XRef : "paper",
YRef : "paper"
),
Annotation.init<double,double,string,string,string,string,string,string,string,string>(
X: 0.225,
Y : 0.4125,
XAnchor: StyleParam.XAnchorPosition.Center,
ShowArrow : false,
YAnchor : StyleParam.YAnchorPosition.Bottom,
Text : "plot3",
XRef : "paper",
YRef : "paper"
),
Annotation.init<double,double,string,string,string,string,string,string,string,string>(
X: 0.775,
Y : 0.4125,
XAnchor: StyleParam.XAnchorPosition.Center,
ShowArrow : false,
YAnchor : StyleParam.YAnchorPosition.Bottom,
Text : "plot4",
XRef : "paper",
YRef : "paper"
)
}
) |
Also maybe to add some context for this, this is by design. You always only have one layout for a chart.
This also means that there can always be only one So for individual subplot titles, you always have to set annotations. We should also provide an abstraction for that, ideally with an |
Thanks a lot for the quick and thorough answer! I tried to implement it and it works I still have to manually set X and Y properties for each annotation. Is there an easy formula to calculate these coordinates, say at the top-center of each subplot? |
Revisiting this for finally releasing v5. Found this 6(!) year old issue plotly/plotly.js#2746 in plotly.js that basically says that we have to use a workaround, since plotly.js does not support this out of the box (and without a sponsor most likely never will) as it has no complete "subplot" concept. This means that |
Description
I code in C#. I'm trying to plot a grid of subplots in which each subplot has its own title displayed on top of it. When I run the code below, the title of the last graph is displayed on top of the first graph and all other titles are missing. "stepCharts" is an array of GenericCharts.
GenericChart.GenericChart allCharts = Plotly.NET.CSharp.Chart.Grid(stepCharts, nRows, nCols);
I noted that my variable "allCharts" has a single layout while each chart in "stepCharts" has its own layout with the right title.
How can I solve this? Also, is there a Plotly.NET equivalent to Python's Plotly function "make_subplots"?
Related information
The text was updated successfully, but these errors were encountered: