如何在每个元素的x轴上显示标签? [英] How to show labels on x axis for each element?
问题描述
我有包含文件名和数字的元组序列.
I have sequence of tuples containing filename and number.
我想绘制在X轴上有文件名的柱形图.
I want to draw column graph where on X axis I have filenames.
我的问题是,现在X轴下仅显示3个标签(文件名).这可能是因为屏幕上无法容纳更多内容.还是X轴间隔错误?
My problem is that now only 3 labels (filenames) are shown under X axis. That's probably because more can't fit on screen. Or maybe X axis interval is wrong?
如何使图表显示所有文件名?也许有一种方法可以将这些标签逆时针旋转90度,以便为更多标签腾出空间?
How to make chart display all filenames? Maybe there is a way to rotate those labels 90 degrees counterclockwise to make room for more labels?
推荐答案
您应该可以使用:
|> Chart.WithXAxis (LabelStyle = ChartTypes.LabelStyle(Angle = -45, Interval = 1.0))
-45度的角度提供了一个很好的斜率,而1.0的间隔意味着没有任何东西被排除.
The angle of -45 gives a nice slope and the interval of 1.0 means nothing is excluded.
这是我在FSI中提出的概念证明:
Here's a proof of concept I knocked up in FSI:
#load "C:/Somewhere/packages/FSharp.Charting.0.90.7/FSharp.Charting.fsx"
open FSharp.Charting;;
let data =
[
("Foo.jpg", 12)
("Bar.jpg", 22)
("Another.doc", 8)
("OneMore.txt", 15)
("LastOne.txt", 17)
("ReallyLastOne.txt", 6)
("Foo.jpg", 12)
("Bar.jpg", 22)
("Another.doc", 8)
("OneMore.txt", 15)
("LastOne.txt", 17)
("ReallyLastOne.txt", 6)
];;
data
|> Chart.Line
|> Chart.WithXAxis (LabelStyle = ChartTypes.LabelStyle(Angle = -45, Interval = 1.0))
;;
这篇关于如何在每个元素的x轴上显示标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!