garvitkhatri created this room.

Hi Anu,

This is a conpherence room where we may have our main discussion about your project, like what things can be added and what path we should take.

Hi Alexander,

I had a healthy discussion over her problem and we have finally solved her issue and she is able to build LabPlot successfully.

Jun 11th, 2016
anumittal edited this Conpherence Room.


What all options must be added in the advance setting of histogram?
From the function of printing a histogram under the gsl library[1] I can see, we will be needing a input file, containing all the data values, histogram pointer, range and bins
int gsl_histogram_fprintf (FILE * stream, const gsl_histogram * h, const char * range_format, const char * bin_format)

please help me in deciding the options to be added in the advance settings widget. :)

[1] https://www.gnu.org/software/gsl/manual/html_node/Reading-and-writing-histograms.html#Reading-and-writing-histograms

Hi Anu,

As discussed, you should look out for a different function, and there are many other functions. If you go through the documentation, this is for writing a stream of data go through [1], [2] and [3]. We don't need to read histogram from a file we just need to store it in a struct so that we can perform actions on it and then save it finally in ours .lml file

For advanced setting you can change the colour of bins, number of bins, selecting your X and Y data. If time allows us, we can at the end have the option to change the colour of border of bins. So these all setting can go inside the settings of a histogram.

[1]. https://www.gnu.org/software/gsl/manual/html_node/Histograms.html
[2]. https://www.gnu.org/software/gsl/manual/html_node/The-histogram-struct.html#The-histogram-struct
[3]. https://www.gnu.org/software/gsl/manual/html_node/Histogram-allocation.html#Histogram-allocation

anumittal edited this Conpherence Room.

Thanks, i will got through the references
One more query: instead of adding the types of histogram option under
worksheet > add new > histogram > types

should'nt it be added under histogram > add new > types ?

Jun 12th, 2016

Hi Anu,

the histogram should be handled like a curve. You add this object to an existing cartesian plot. It should be possible to combine histograms and curves in the same plot to do the analysis like shown here for example
http://home.gna.org/veusz/examples/ (histogram example).

Also, the histogram type (ordinary, cummulative, average shifted) is just one of the many properties of this object and should be handled like this. So, in the "Add new"-menu you only have "Historgram" as a new type of objects that can be added to a plot. The properties of that object can then be changed in the corresponding dock widget. The user will then be able to switch between the different histogram types on the fly and see the changes immediately in the plot. Just to compare once more with the curve, for XYCurve we don't have in the "add new" menu entries like "XYCurve with lines", "XYCurve with lines and symbols", "XYCurve with lines and with drop lines" etc. - all those things are properties of the same object and not different objects.

regarding reading from a file: we don't do this in LabPlot. We import the file into the project first (into a spreadsheet) and provide columns as the data source for objects that can be plotted (xy-curve, xy-fit-curve, histogram, etc.). When using GSL, we convert those objects internally to objects that can be consuming by GSL. Basically we copy the data from our containers (Column with a QVector<double>) to GSL structures. Also, you need to take care of masked data - those data should be skipped when calculating the histogram.

Have a look at XYFitCurvePrivate::recalculate() to see how things like this are handled.

Jun 15th, 2016
asemke added a participant: sgerlach.
Jun 30th, 2016

Thank you for your support team Labplot. I got feedback from Garvit about my performance till the mid-term evaluation and I will continue to work hard to make the most out of last 6 weeks.
Now moving on to the implementation of histogram, I had a discussion with Garvit and what we thought of is:
First, we can find out the maximum and minimum value of data from the given set of data through which we will get the range (= max - min).
Number of bins will be entered by the user, say n.
Now through these two values, we can calculate the width of histogram column (width = range/n) .
Lastly, creating an array which will store the column height, calculated by iterating through each value and finding width range to which the values belong (adding up the count of values in particular range).
This array will be used to paint histogram bars of equivalent height for the calculated range.
Probably this should work for both negative and positive value.
Is this an appropriate method to implement it? If not please guide me to the correct approach.

Hi Anu,

this sounds exactly like the histogram functions from GSL. Did you take a look at the example at https://www.gnu.org/software/gsl/manual/html_node/Example-programs-for-histograms.html
I think using GSL would make things easier.

Jul 3rd, 2016

Hi Anu,

to determine min and max you can use already available functions Column::minimum() and Column::maximum().

The number of bins should be an adjustable parameter in the dock widget. The user either enters the number of bins, the width of the bin or selects one of the prescriptions (rules) for the "optimal number of bins" as described here https://en.wikipedia.org/wiki/Histogram#Number_of_bins_and_width
So, in the dock widget you add a label "Bins" and the combobox with "By Number", "By width", "Square-root rule", "Rice rule", etc. If the user selects "By Number" or "By width" you show an additional text field where the value can be entered and hide it otherwise.

For the ordinary histogram you can use GSL as Stefan already mentioned. I don't think GSL supports cumulative and average shifted histograms. Please check it. If not, write your own code to calculate these two types of histograms. Stefan, maybe we can add these functions later to NSL.

Once you have the positions of the bins and there heights, you can calculate the QPainterPath of the histogram and draw it in paint() according to the settings the user did in the dock widget (line type, width, color, filling, etc.). You can have a look at


to get the idea of which options are available for the historgram.

Jul 11th, 2016

Hi Anu,

how is the progress? Do you need some more information about this?


Jul 12th, 2016
anumittal edited this Conpherence Room.

I have printed a static ordinary histogram with the help of Garvit. I have pushed the code in the "histogram_chart" branch and it looks like this:

Currenlty it works only for two axis and to see it we have to adjust x-range and y-range as shown in screenshot. My next task is to make this code work for other types of graph and scale the axis automatically.

Aug 5th, 2016

I have implemented and pushed the logic for the ordinary and cumulative histogram,
-> need help for Avg shifted histogram. Please help me with the logic or an example.
Also, currently the plot is not able to change form dynamically according to the input (by taking bins according to rice rule first and then change it to by number), I am working on that.

->Which function is used to make a plot or curve selectable?( So that after clicking on it, its properties are opened in the dock widgets)

anumittal edited this Conpherence Room.

Can you please tell me what could be the reason behind the shadow retention in the histogram plot.

Also, do we need values tab in the dock widget for the histogram? It shows all the values which have been counted in a particular bin. If yes, then i guess we have to change the format as it is not readable in the current one.

Aug 6th, 2016

For the average shifted histogram, please check this publication and the examples therein.

The connection between the selection in the project explorer and the shown dock widget is done in GuiObserver.cpp - the logic is straight-forward.

Regarding the problem with the values - for the xy-curve we show the actual values of the data points. This is what you have now in the current implementation of the histogram. So, many many values are shown which looks broken like on your screenshot. You"ll need to adjust the logic in your code accordingly and to show the accumulated histogram values and not the values of the actual data points.

Aug 7th, 2016

Hi Alexander, I have helped her with all the points mentioned except to make a curve selectable by this she means the when we hover over a curve it gets highlighted and when you click it, it gets selected in the project explorer and we see curve's properties in dock widget. This happens due to the event hoverEnterEvent and hoverLeaveEvent of QGraphicsItem. I am also looking into how to solve it but it would be great if you could help us here.

Hi Garvit, I don't have the access to the code right now so I cannot check the current implementation of the histogram. Each WorksheetElement has two boolean members m_selected and m_hovered. In the paint() method each worksheet element has to handle these two states. Please check xycurrve:: paint() for this. Also, the actual QGraphicsItem of the worksheet element have to accept the select and hover events. But I think this is already the case for the histogram...

Aug 12th, 2016

I am not able to figure out the reason behind shadow retention in the histogram plot. (asked earlier, screenshot included)
Please guide me.

I have resolved the issue :) no more shadows in histogram!