add log-y for histogram 1

This commit is contained in:
carina@hades 2023-12-14 15:45:02 -05:00
parent 495d65a112
commit d90dd4920f

View File

@ -12,6 +12,8 @@ class Histogram1D : public QCustomPlot{
public: public:
Histogram1D(QString title, QString xLabel, int xbin, double xmin, double xmax, QWidget * parent = nullptr) : QCustomPlot(parent){ Histogram1D(QString title, QString xLabel, int xbin, double xmin, double xmax, QWidget * parent = nullptr) : QCustomPlot(parent){
isLogY = false;
for( int i = 0; i < 3; i ++) txt[i] = nullptr; for( int i = 0; i < 3; i ++) txt[i] = nullptr;
nData = 1; nData = 1;
Rebin(xbin, xmin, xmax); Rebin(xbin, xmin, xmax);
@ -82,6 +84,7 @@ public:
QMenu menu(this); QMenu menu(this);
QAction * a1 = menu.addAction("UnZoom"); QAction * a1 = menu.addAction("UnZoom");
QAction * a5 = menu.addAction("Set/UnSet Log-y");
QAction * a2 = menu.addAction("Clear hist."); QAction * a2 = menu.addAction("Clear hist.");
QAction * a3 = menu.addAction("Toggle Stat."); QAction * a3 = menu.addAction("Toggle Stat.");
QAction * a4 = menu.addAction("Rebin (clear histogram)"); QAction * a4 = menu.addAction("Rebin (clear histogram)");
@ -170,6 +173,17 @@ public:
} }
} }
if( selectedAction == a5 ){
if( !isLogY ){
this->yAxis->setScaleType(QCPAxis::stLogarithmic);
isLogY = true;
}else{
this->yAxis->setScaleType(QCPAxis::stLinear);
isLogY = false;
}
this->replot();
}
} }
}); });
@ -294,6 +308,8 @@ private:
int underFlow; int underFlow;
int overFlow; int overFlow;
bool isLogY;
unsigned short nData; unsigned short nData;
QVector<double> xList; QVector<double> xList;
QVector<double> yList[MaxNHist]; QVector<double> yList[MaxNHist];