Skip to content

How do I make the bars of Scottplot reside exactly between the hours? #2663

@Jay-Aberlour

Description

@Jay-Aberlour

ScottPlot Version: 4.1.63
Operating System: Windows 11
Application Type: WinForms

Question: I am trying to create a bar chart which gives hourly values. The values can be shown for days in the past or for the current day. At this point in time, a day has a maximum of 18 hours, but this could change in the future. I used to put the values on the whole hour,
Schermafbeelding 2023-05-26 083435
but my colleague remarked that it could be hard to see which hour was meant (if the bar is on 12:00h, does the bar then represent from 11h-12h or from 12h-13h?). To solve this, I want to have the left side of the bar at the start of the hour and the right side of that bar at the end.
Schermafbeelding 2023-05-26 084024
This example is almost what I want, but the beginning and end are not exactly on the whole hour. It is less noticable in this example, but when there are less hours or somebody zooms in it becomes very clear.
Schermafbeelding 2023-05-26 084431

How do I make the bars of Scottplot reside between the exact hours?

The first plot is made following the ScottPlot cookbook. The code used to create the latter two plots:

var bar = plt_values.Plot.AddBar(collection.Values.ToArray(), collection.Keys.ToArray());
bar.BarWidth = (1.0 / 19) * .8;

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