Skip to main content
`Ctrl`+`K`

# PetscDrawHGCreate

Creates a histogram data structure.

## Synopsis

    #include "petscdraw.h"
    #include "petscsys.h"
    #include "petscviewer.h"
    PetscErrorCode PetscDrawHGCreate(PetscDraw draw, int bins, PetscDrawHG *hist)

Collective

## Input Parameters

- draw - The window where the graph will be made

- bins - The number of bins to use

## Output Parameter

- hist - The histogram context

## Notes

The difference between a bar chart, `PetscDrawBar`, and a histogram, `PetscDrawHG`, is explained here https://stattrek.com/statistics/charts/histogram.aspx?Tutorial=AP

The histogram is only displayed when `PetscDrawHGDraw()` is called.

The MPI communicator that owns the `PetscDraw` owns this `PetscDrawHG`, but the calls to set options and add data are ignored on all processes except the zeroth MPI process in the communicator. All MPI processes in the communicator must call `PetscDrawHGDraw()` to display the updated graph.

## See Also

`PetscDrawHGDestroy()`, `PetscDrawHG`, `PetscDrawBarCreate()`, `PetscDrawBar`, `PetscDrawLGCreate()`, `PetscDrawLG`, `PetscDrawSPCreate()`, `PetscDrawSP`, `PetscDrawHGSetNumberBins()`, `PetscDrawHGReset()`, `PetscDrawHGAddValue()`, `PetscDrawHGDraw()`, `PetscDrawHGSave()`, `PetscDrawHGView()`, `PetscDrawHGSetColor()`, `PetscDrawHGSetLimits()`, `PetscDrawHGCalcStats()`, `PetscDrawHGIntegerBins()`, `PetscDrawHGGetAxis()`, `PetscDrawAxis`, `PetscDrawHGGetDraw()`

## Level

intermediate

## Location

src/sys/classes/draw/utils/hists.c

Index of all Draw routines
Table of Contents for all manual pages
Index of all manual pages