Skip to content

Create a bar plot without defining X positions #640

@bukkideme

Description

@bukkideme

Hi!

It is a common case when we need to visualize XY data pairs on a Bar graph. However, often we need to show the Y-values/bars side-by-side of each others, therefore we need to code extra lines not to directly use the raw X-values for the PlotBar() methode.

Example what I need to do now for this:

double[] xs = { 0, 5, 10, 20, 40, 80 };
double[] ys = { 0.02, 0.01, 0.01, 0.02, 0.04, 0.03 };
int barCount = xs.Length; 
//artificial X values to make Bars side by side without data gaps in X-axis:
double[] x_consecutive = DataGen.Consecutive(barCount);
                        
// make the bar plot
formsPlot1.plt.PlotBar(x_consecutive, ys);
                        
// apply custom axis tick labels
formsPlot1.plt.XTicks(x_consecutive, xs.Select(item => item.ToString()).ToArray());
formsPlot1.Render();

It would be great to have an extra parameter for the PlotBar() method, like "consecutive_X_vals". If this set to True, the plot would take the string representations of the X-values, and plot the Y-values side by side, with labels from the X-values.
In this way we avoid the extra required coding.
Thanks! :)

image

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