int main(int argc, char *argv[]) { std::cout << "Background solid color demo" << std::endl; QApplication a(argc, argv); WPlot::Plot2D* plot2D(new WPlot::Plot2D); WPlot::Background::Ptr background(new WPlot::Background); background->setColor(Qt::yellow); plot2D->setBackground(background); plot2D->show(); return a.exec(); }
int main(int argc, char *argv[]) { std::cout << "Styled text inset demo" << std::endl; QApplication a(argc, argv); WPlot::CartesianPlot2D* plot2D(new WPlot::CartesianPlot2D); WPlot::Ticks2D::Ptr ticks(new WPlot::Ticks2D); WPlot::Axes2D::Ptr axes(new WPlot::Axes2D); ticks->setOrigin(150.0, 200.0); ticks->setPrimaryTickLength(20); ticks->setEnableLabels(true); axes->setTicks(ticks); plot2D->setPadding(25, WPlot::Padding::PIXELS); plot2D->setPlotLimits(-3.3, 7.5, -2, 4.3); plot2D->addAxes(axes); plot2D->show(); return a.exec(); }
int main(int argc, char *argv[]) { std::cout << "Simple circle inset demo" << std::endl; QApplication a(argc, argv); WPlot::PolarPlot2D* plot2D(new WPlot::PolarPlot2D); WPlot::PolarLineGraph2D::Ptr lineGraph(new WPlot::PolarLineGraph2D); WPlot::PolarGrid2D::Ptr grid(new WPlot::PolarGrid2D); auto f = colorFunction; for (double x = 0.0; x < 3.14; x += 0.01) { lineGraph->appendPoint(x, sin(x)); } lineGraph->setLineWidth(3.0); lineGraph->setColorFunction(f); plot2D->setPadding(25, WPlot::Padding::PIXELS); plot2D->addGraph(lineGraph); plot2D->addGrid(grid); plot2D->show(); return a.exec(); }
int main(int argc, char *argv[]) { std::cout << "Styled rectangle inset demo" << std::endl; QApplication a(argc, argv); WPlot::CartesianPlot2D* plot2D(new WPlot::CartesianPlot2D); WPlot::Rectangle::Ptr rectangle(new WPlot::Rectangle); rectangle->setCoordinates(WPlot::Item2D::COORDINATE_PLOT, WPlot::Item2D::AXIS_X); rectangle->setDimensions(2.0, 1.7); rectangle->setPivot(0.0, 0.0); rectangle->setLineColor(Qt::red); rectangle->setLineWidth(2.5); rectangle->setLineStyle(Qt::DashDotLine); rectangle->setFillColor(Qt::blue); plot2D->setPadding(25, WPlot::Padding::PIXELS); plot2D->setPlotLimits(-3, 7.5, -2, 4.3); plot2D->addItem(rectangle); plot2D->show(); return a.exec(); }
int main(int argc, char *argv[]) { std::cout << "Simple circle inset demo" << std::endl; QApplication a(argc, argv); WPlot::CartesianPlot2D* plot2D(new WPlot::CartesianPlot2D); WPlot::OHLCGraph2D::Ptr ohlcGraph(new WPlot::OHLCGraph2D); WPlot::CartesianGrid2D::Ptr grid(new WPlot::CartesianGrid2D); for (double x = 0.0; x < 8.0; x += 0.2) { const double open = sin(x * 0.6) + 2; const double high = sin(x * 0.4) + 3; const double low = sin(x * 0.8) - 2; const double close = sin(x * 0.7) - 1; ohlcGraph->appendOHLC(x, open, high, low, close); } plot2D->setPadding(25, WPlot::Padding::PIXELS); plot2D->setPlotLimits(-1, 8.5, -4.0, 4.0); plot2D->addGraph(ohlcGraph); plot2D->addGrid(grid); plot2D->show(); return a.exec(); }
void PlotWizard::accept() { QStringList curves, curves3D, ribbons; for (int i=0; i < plotAssociations->count(); i++){ QString text = plotAssociations->item(i)->text(); if (text.endsWith("(X)")){ QMessageBox::critical(this, tr("QtiPlot - Error"), tr("Please define a Y column for the following curve") + ":\n\n" + text); return; } if ( text.contains("(Z)") ){ if ( text.contains("(Y)") && !curves3D.contains(text) ) curves3D << text; else if ( !text.contains("(Y)") && !ribbons.contains(text) ) ribbons << text; } else if ( text.contains("(xErr)") || text.contains("(yErr)")){ QStringList lst = text.split(",", QString::SkipEmptyParts); lst.pop_back(); QString master_curve = lst.join(","); if (!curves.contains(master_curve)) curves.prepend(master_curve); if (!curves.contains(text)) curves << text; //add error bars at the end of the list. } else curves.prepend(text); } if (curves.count()>0) plot2D(curves); if (curves3D.count()>0) plot3D(curves3D); if (ribbons.count()>0) plot3DRibbon(ribbons); if(!noCurves()) close(); }
int main(int argc, char *argv[]) { std::cout << "Simple circle inset demo" << std::endl; QApplication a(argc, argv); WPlot::CartesianPlot2D* plot2D(new WPlot::CartesianPlot2D); WPlot::Circle::Ptr circlePlot(new WPlot::Circle); WPlot::CartesianScatterGraph2D::Ptr scatterGraph(new WPlot::CartesianScatterGraph2D); WPlot::CartesianGrid2D::Ptr grid(new WPlot::CartesianGrid2D); // Here we use the plot coordinate system circlePlot->setPivotCoordinates(WPlot::Item2D::COORDINATE_PLOT, WPlot::Item2D::AXIS_X); circlePlot->setDimensionCoordinates(WPlot::Item2D::COORDINATE_WIDGET, WPlot::Item2D::AXIS_X); circlePlot->setRadius(10); scatterGraph->setItem(circlePlot); for (double x = 0.0; x < 8.0; x += 0.2) { scatterGraph->appendPoint(x, sin(x)); } plot2D->setPadding(25, WPlot::Padding::PIXELS); plot2D->setPlotLimits(-1, 8.5, -1.0, 1.0); plot2D->addGraph(scatterGraph); plot2D->addGrid(grid); plot2D->show(); return a.exec(); }
//============================================================================= // Main execution //============================================================================= StatusCode PrPixelMonitor::execute() { const unsigned int nHits = m_hitManager->nbHits(); const unsigned int nHitsUsed = m_hitManager->nbHitsUsed(); plot(nHits, "HitsPerEvent", "Number of hits per event", 0.0, 8000.0, 80); if (nHits > 0) { plot(100. * nHitsUsed / nHits, "PercentUsedHitsPerEvent", "Percentage of hits assigned to tracks", 0.0, 100.0, 100); } LHCb::Tracks* tracks = getIfExists<LHCb::Tracks>(LHCb::TrackLocation::Velo); if (!tracks) { warning() << "No tracks in " << LHCb::TrackLocation::Velo << endmsg; return StatusCode::FAILURE; } plot(tracks->size(), "TracksPerEvent", "Number of tracks per event", 0., 800., 80); LHCb::VPClusters* clusters = getIfExists<LHCb::VPClusters>(LHCb::VPClusterLocation::Default); if (!clusters) { warning() << "No clusters in " << LHCb::VPClusterLocation::Default << endmsg; } unsigned int nFwd = 0; unsigned int nBwd = 0; for (LHCb::Track* track : *tracks) { const bool bwd = track->checkFlag(LHCb::Track::Backward); const unsigned int nHitsPerTrack = track->lhcbIDs().size(); const float chi2 = track->chi2PerDoF(); const float eta = track->pseudoRapidity(); const float phi = track->phi() / Gaudi::Units::degree; if (bwd) { ++nBwd; plot(nHitsPerTrack, "BwdHitsPerTrack", "Number of hits per backward track", 0.5, 40.5, 40); plot(chi2, "BwdChi2", "Chi2/DoF of backward tracks", 0., 10., 50); plot(eta, "BwdEta", "Pseudorapidity of backward tracks", 1., 6., 50); plot(phi, "BwdPhi", "Phi-angle of backward tracks", -180., 180., 60); plot2D(eta, nHitsPerTrack, "BwdHitsPerTrackVsEta", "Hits/track vs pseudorapidity of backward tracks", 1., 6., 0.5, 15.5, 50, 15); plot2D(eta, chi2, "BwdChi2VsEta", "Chi2/DoF vs pseudorapidity of backward tracks", 1., 6., 0., 10., 50, 20); plot2D(nHitsPerTrack, chi2, "BwdChi2VsHitsPerTrack", "Chi2/DoF vs hits/backward track", 0.5, 15.5, 0., 10., 15, 20); } else { ++nFwd; plot(nHitsPerTrack, "FwdHitsPerTrack", "Number of hits per forward track", 0.5, 40.5, 40); plot(chi2, "FwdChi2", "Chi2/DoF of forward tracks", 0., 10., 50); plot(eta, "FwdEta", "Pseudorapidity of forward tracks", 1., 6., 50); plot(phi, "FwdPhi", "Phi-angle of forward tracks", -180., 180., 60); plot2D(eta, nHitsPerTrack, "FwdHitsPerTrackVsEta", "Hits/track vs pseudorapidity of forward tracks", 1., 6., 0.5, 15.5, 50, 15); plot2D(eta, chi2, "FwdChi2VsEta", "Chi2/DoF vs pseudorapidity of forward tracks", 1., 6., 0., 10., 50, 20); plot2D(nHitsPerTrack, chi2, "FwdChi2VsHitsPerTrack", "Chi2/DoF vs hits/forward track", 0.5, 15.5, 0., 10., 15, 20); } if (!clusters) continue; // Calculate radius at first and last hit // (assume that hits are sorted by module) const LHCb::VPChannelID id0 = track->lhcbIDs().front().vpID(); const LHCb::VPChannelID id1 = track->lhcbIDs().back().vpID(); const LHCb::VPCluster* cluster0 = clusters->object(id0); if (!cluster0) continue; const LHCb::VPCluster* cluster1 = clusters->object(id1); if (!cluster1) continue; const float x0 = cluster0->x(); const float y0 = cluster0->y(); const float r0 = sqrt(x0 * x0 + y0 * y0); const float x1 = cluster1->x(); const float y1 = cluster1->y(); const float r1 = sqrt(x1 * x1 + y1 * y1); const float minR = r0 > r1 ? r1 : r0; const float maxR = r0 > r1 ? r0 : r1; plot(minR, "MinHitRadius", "Smallest hit radius [mm]", 0., 50., 100); plot(maxR, "MaxHitRadius", "Largest hit radius [mm]", 0., 50., 100); } plot(nFwd, "FwdTracksPerEvent", "Number of forward tracks per event", 0., 400., 40); plot(nBwd, "BwdTracksPerEvent", "Number of backward tracks per event", 0., 400., 40); return StatusCode::SUCCESS; }