@alexcjohnson
Hmm... not sure if this is a bug?
It goes down to here:
https://github.com/plotly/plotly.js/blob/bee245587214ed5f1fcc23fcad8006eb75f7cfe2/src/plots/cartesian/layout_defaults.js#L219-L221
Should we support template for axes?
I think the problem is a little more subtle than that. We do support templating axes, but currently Lib.coerce2 does not consider a template value to be "non-default."
Consider: just adding empty containers for the axes also doesn't show the ticks:
Plotly.newPlot(gd, {
data: data,
layout: {
template: {layout: layout},
yaxis: {},
xaxis: {}
}
});
But if you explicitly turn the ticks on they have the style from the template:
Plotly.newPlot(gd, {
data: data,
layout: {
template: {layout: layout},
yaxis: {ticks: 'outside'},
xaxis: {ticks: 'inside'}
}
});
And if you turn ticks on explicitly from the template, that also makes them appear:
var layout = {
"yaxis": {
"type": "log",
"tickwidth": 5,
"tickcolor": "green",
ticks: 'outside'
},
"xaxis": {
"type": "date",
"tickwidth": 50,
"tickcolor": "red",
ticks: 'outside'
}
};
Plotly.newPlot(gd, {
data: data,
layout: {
template: {layout: layout}
}
});
What's happening is in this block:
Lib.coerce2 returns false because no user value was provided, even though the template provided a value. So ticks defaults to '' rather than 'outside'.
In this particular case I think it's clear that we want to consider the template value to be "non-default" and to therefore cause ticks to be shown. I _think_ that's a generally true statement, following from the principle that layout: obj should produce equivalent output to layout: {template: {layout: obj}}, so we should fix that at the level of Lib.coerce2, but we should explore some of the other uses of Lib.coerce2 before deciding that for sure.
Reopening after the revert by #5016.
is it true that we can't set the tickwidth etc in the template ? or just that we have to also show the ticks from the template?
We were unable to set that before v1.54.4. Now moving forward with v1.54.7, again we cannot set that.
I can't agree with "we cannot set that" ... if you also set ticks: "outside" in the template then you'll see that the provided tickwidth values in the template are indeed set in the figure. So the problem is not precisely "you can't set it", the problem is that "setting it doesn't also trigger all the other default behaviours it does when it's set in the layout".