How to show labels on x axis for each element?

戏子无情 提交于 2019-12-10 21:57:51

问题


I have sequence of tuples containing filename and number.

I want to draw column graph where on X axis I have filenames.

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?

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?


回答1:


You should be able to use:

|> Chart.WithXAxis (LabelStyle = ChartTypes.LabelStyle(Angle = -45, Interval = 1.0))

The angle of -45 gives a nice slope and the interval of 1.0 means nothing is excluded.

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))
    ;;



来源:https://stackoverflow.com/questions/27933470/how-to-show-labels-on-x-axis-for-each-element

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!