简体   繁体   English

Plotly.js,如何增加在plotly.js Bar x轴上用于文本的区域?

[英]Plotly.js , How to increase the area devoted for the text in plotly.js Bar x axis?

How to increase the area devoted for the text in plotly.js Bar x axis? 如何增加在plotly.js条形x轴上用于文本的区域? CUrrently, the values of x axis are "text very long and longer 1", "text very long and longer 2", "text very long and longer 3". 当前,x轴的值为“很长很长的文本1”,“很长很长的文本2”,“很长很长的文本3”。 After plotting, i am getting the image where the text is cutted and remains only "text very lon", "text very lon", "text very lon". 绘制后,我得到的图像被剪切掉,并且仅保留“ text lon”,“ text lon”,“ text lon”。

You can use margin to manually define the borders of your graph, see the snippet below. 您可以使用margin来手动定义图形的边框,请参见下面的代码段。

 var layout = { autosize: false, width: 600, height: 500, margin: { l: 50, r: 350, b: 200, t: 50, pad: 4 } }; var data = [{ x: ["text very long and longer 1", "extremely long text 2", "extremely long text with some extra characters 3", "the longest text, probably most useless x-axis caption ever 4"], y: [10, 15, 13, 17], mode: 'markers', type: 'scatter' }]; Plotly.newPlot('myDivNoLayout', data); Plotly.newPlot('myDiv', data, layout); 
 <head> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> </head> <div id='myDivNoLayout'></div> <div id='myDiv'></div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM