Subtitles for PieCharts in a pretty way


Hi, I create piecharts with many subplots inside and want to label each pie-chart. The number of sub-piecharts is dynamically (e.g just one or twelve). How can I labeling beautiful each sub-piechart? Of course the approach is to use annotations. But how to set the correct x,y to center them.

I tried some algorithms for specify, where the sub-piechart should be and where the label should be. But e.g. if the plot size varies from to screen size to screen size it looks different. Are there any smart tricks for achieve my goal? (centering the label above each sub-piechart). My minimum example is this:

Its sets the position of each piechart dynamically and also for the annotation/label

//iterate dynamically over piecharts and put the name as subtitle of the plot
var annotations=[];
var xPerTrace = 1/data.length;
var startX = 0;
for(var i = 0; i<data.length; i++){
	//set domain of 
  	x:[startX, startX+xPerTrace],

  //create annotation for it
		    font: {
	          size: 10
	        xanchor: 'left',
	        yanchor: 'bottom',
	        xref: 'paper',
	        showarrow: false,
	        text: data[i].name,
	        x: startX,
	        y: 0//,
	        //bgcolor: "rgba(255,33,22,0)"
    //increase startX

Guidence in setting up titles in pie chart subplots

You’re probably pretty close.

Have you tried setting xanchor and yanchor in each of your annotations to help you position them correctly?




Hey @etienne: Thank you very much for this hint. I think I solved my problem and will check it for my plot code. Here is the solution for my min-example I have given you: