Skip to content

Centered labels in horizontal bars #3533

@TheFizz

Description

@TheFizz

ScottPlot Version: 5.0.22

Hey. Thank you very much for ScottPlot, very convenient and intuitive.

However, I am having a hard time aligning the labels inside horizontally stacked bars.
I am using a WinForms library (if this changes anything)

I can use offsetY like this

var barPlot = PlotView.Plot.Add.Bars(bars);
barPlot.Horizontal = true;
barPlot.ValueLabelStyle.OffsetY = 30;

To produce result like this
image

but the moment I change the number of bars it breaks =/
image

This is not too surprising (given that the bar width had changed). On this note I have a couple of questions I didn't find answers to

  1. Is it possible to set bars to constant width (so I can use the same offset)
  2. Is it possible to read the bar width (and adjust offset accordingly)
  3. Maybe there is an alignment option I missed? (I know there is barPlot.ValueLabelStyle.Alignment = Alignment.MiddleCenter; but it works weird)

This is without offset with MiddleCenter alignment
image

I appreciate your work
Thanks in advance
-Sev

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions