void scopePlot::add3(double *data, unsigned long len,QString curveName,QString yRightLabel) { c3.resize(len); for (unsigned long i = 0; i < len; i++) { c3[i]=data[i]; } plot3(curveName,yRightLabel); }
void MainWindow::updatePlot() { horiz_swipe(0,true); order = get_order(); ui->order->setText(QApplication::translate("MainWindow", std::to_string(order).c_str(), 0)); ui->ripple->setText(QApplication::translate("MainWindow", std::to_string(ripple()).c_str(), 0)); ui->fc->setText(QApplication::translate("MainWindow", std::to_string(fc()).c_str(), 0)); ui->customPlot->graph()->clearData(); plot3(ui->customPlot); }
void plotParitialDegDistribution(const PNGraph& graph, std::vector<int>& nodeList) { std::map<int, int> inDegDistMap; std::map<int, int> outDegDistMap; for (int i = 0; i < nodeList.size(); ++i) { int curNodeId = nodeList[i]; if (!graph->IsNode(curNodeId)) continue; TNGraph::TNodeI ni = graph->GetNI(curNodeId); int curNodeInDeg = ni.GetInDeg(); if (inDegDistMap.find(curNodeInDeg) == inDegDistMap.end()) { inDegDistMap.insert(std::pair<int, int>(curNodeInDeg, 0)); } inDegDistMap[curNodeInDeg]++; int curNodeOutDeg = ni.GetOutDeg(); if (outDegDistMap.find(curNodeOutDeg) == outDegDistMap.end()) { outDegDistMap.insert(std::pair<int, int>(curNodeOutDeg, 0)); } outDegDistMap[curNodeOutDeg]++; } TFltPrV inDegDist; for (std::map<int, int>::iterator itr = inDegDistMap.begin(); itr != inDegDistMap.end(); itr++) { inDegDist.Add(TFltPr(itr->first, itr->second)); } TFltPrV outDegDist; for (std::map<int, int>::iterator itr = outDegDistMap.begin(); itr != outDegDistMap.end(); itr++) { outDegDist.Add(TFltPr(itr->first, itr->second)); } TGnuPlot plot1("inDegDistParitial", ""); plot1.AddPlot(inDegDist, gpwPoints, ""); plot1.SetScale(gpsLog10XY); plot1.SavePng(); TGnuPlot plot2("outDegDistParitial", ""); plot2.AddPlot(outDegDist, gpwPoints, ""); plot2.SetScale(gpsLog10XY); plot2.SavePng(); TGnuPlot plot3("DegDistParitial", ""); plot3.AddCmd("set key right top"); plot3.AddPlot(inDegDist, gpwPoints, "In Degree"); plot3.AddPlot(outDegDist, gpwPoints, "Out Degree"); plot3.SetScale(gpsLog10XY); plot3.SavePng(); }
void MainWindow::graphMoveEvent(QMouseEvent *event) { if (!(event->buttons() & Qt::LeftButton)) return; if (((event->pos() - dragStartPosition).manhattanLength()) < QApplication::startDragDistance()) return; BoxChecked(true); QPoint dis = (event->pos() - dragStartPosition); double xdis = dis.x(); double ydis = dis.y(); double x = M_PI*event->pos().x()/600.0; double y = event->pos().y()/400.0; double m = get_mag(x); bool in_passband = (m>-3); double y_db = -100.0*y + 10; bool above_stop = (-y_db < m); if (fabs(xdis) > fabs(ydis)) { // Bandpass or Bandstop if (get_filter_type() > 1) { set_center(xdis); } else { horiz_swipe(xdis,in_passband); } } else { vertical_swipe(-ydis,in_passband,above_stop); } order = get_order(); ui->order->setText(QApplication::translate("MainWindow", std::to_string(order).c_str(), 0)); ui->ripple->setText(QApplication::translate("MainWindow", std::to_string(ripple()).c_str(), 0)); ui->fc->setText(QApplication::translate("MainWindow", std::to_string(fc()).c_str(), 0)); QCPGraph* ptr = GetPtr(); dragStartPosition = event->pos(); if (ptr != NULL) { ui->customPlot->graph()->clearData(); plot3(ui->customPlot); } }
int main( int argc, const char *argv[] ) { int i, j; PLFLT xx, yy; /* Parse and process command line arguments */ (void) plparseopts( &argc, argv, PL_PARSE_FULL ); /* Set up color map 0 */ /* * plscmap0n(3); */ /* Set up color map 1 */ cmap1_init2(); /* Initialize plplot */ plinit(); /* Set up data array */ for ( i = 0; i < XPTS; i++ ) { xx = (double) ( i - ( XPTS / 2 ) ) / (double) ( XPTS / 2 ); for ( j = 0; j < YPTS; j++ ) { yy = (double) ( j - ( YPTS / 2 ) ) / (double) ( YPTS / 2 ) - 1.0; z[i][j] = xx * xx - yy * yy + ( xx - yy ) / ( xx * xx + yy * yy + 0.1 ); } } f2mnmx( &z[0][0], XPTS, YPTS, &zmin, &zmax ); plot1(); plot2(); plot3(); plend(); exit( 0 ); }
void plotDegDistribution(const PNGraph& graph) { TFltPrV outDegDist; TSnap::GetOutDegCnt(graph, outDegDist); TGnuPlot plot1("outDegDist", ""); plot1.AddPlot(outDegDist, gpwPoints, ""); plot1.SetScale(gpsLog10XY); plot1.SavePng(); TFltPrV inDegDist; TSnap::GetInDegCnt(graph, inDegDist); TGnuPlot plot2("inDegDist", ""); plot2.AddPlot(inDegDist, gpwPoints, ""); plot2.SetScale(gpsLog10XY); plot2.SavePng(); TGnuPlot plot3("DegDist", ""); plot3.AddCmd("set key right top"); plot3.AddPlot(inDegDist, gpwPoints, "In degree"); plot3.AddPlot(outDegDist, gpwPoints, "Out degree"); plot3.SetScale(gpsLog10XY); plot3.SavePng(); }
void MainWindow::graphMoveEvent(QMouseEvent *event) { if (!(event->buttons() & Qt::LeftButton)) return; if (((event->pos() - dragStartPosition).manhattanLength()) < QApplication::startDragDistance()) return; QPoint dis = (event->pos() - dragStartPosition); double xdis = dis.x(); double ydis = dis.y(); if (std::abs(xdis) > std::abs(ydis)) { horiz_swipe(xdis,true); } else { vertical_swipe(-ydis,true,true); } QCPGraph* ptr = GetPtr(); dragStartPosition = event->pos(); if (ptr != NULL) { ui->customPlot->graph()->clearData(); plot3(ui->customPlot); } }
int main( int argc, char *argv[] ) { PLINT digmax, cur_strm, new_strm; char ver[80]; // plplot initialization // Parse and process command line arguments plMergeOpts( options, "x01c options", notes ); plparseopts( &argc, argv, PL_PARSE_FULL ); // Get version number, just for kicks plgver( ver ); fprintf( stdout, "PLplot library version: %s\n", ver ); // Initialize plplot // Divide page into 2x2 plots // Note: calling plstar replaces separate calls to plssub and plinit plstar( 2, 2 ); // Select font set as per input flag if ( fontset ) plfontld( 1 ); else plfontld( 0 ); // Set up the data // Original case xscale = 6.; yscale = 1.; xoff = 0.; yoff = 0.; // Do a plot plot1( 0 ); // Set up the data xscale = 1.; yscale = 0.0014; yoff = 0.0185; // Do a plot digmax = 5; plsyax( digmax, 0 ); plot1( 1 ); plot2(); plot3(); // // Show how to save a plot: // Open a new device, make it current, copy parameters, // and replay the plot buffer // if ( f_name ) // command line option '-save filename' { printf( "The current plot was saved in color Postscript under the name `%s'.\n", f_name ); plgstrm( &cur_strm ); // get current stream plmkstrm( &new_strm ); // create a new one plsfnam( f_name ); // file name plsdev( "psc" ); // device type plcpstrm( cur_strm, 0 ); // copy old stream parameters to new stream plreplot(); // do the save by replaying the plot buffer plend1(); // finish the device plsstrm( cur_strm ); // return to previous stream } // Let's get some user input if ( locate_mode ) { for (;; ) { if ( !plGetCursor( &gin ) ) break; if ( gin.keysym == PLK_Escape ) break; pltext(); printf( "subwin = %d, wx = %f, wy = %f, dx = %f, dy = %f\n", gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY ); printf( "keysym = 0x%02x, button = 0x%02x, string = '%s', type = 0x%02x, state = 0x%02x\n", gin.keysym, gin.button, gin.string, gin.type, gin.state ); plgra(); } } // Don't forget to call plend() to finish off! plend(); exit( 0 ); }
void myplot4() { plot3(); }
int main(int argc, char *argv[]) { int i, digmax; int xleng0 = 400, yleng0 = 300, xoff0 = 200, yoff0 = 200; int xleng1 = 400, yleng1 = 300, xoff1 = 500, yoff1 = 500; /* Select either TK or DP driver and use a small window */ /* Using DP results in a crash at the end due to some odd cleanup problems */ /* The geometry strings MUST be in writable memory */ char geometry_master[] = "500x410+100+200"; char geometry_slave[] = "500x410+650+200"; char driver[80]; /* plplot initialization */ /* Parse and process command line arguments */ (void) plparseopts(&argc, argv, PL_PARSE_FULL); plgdev(driver); printf("Demo of multiple output streams via the %s driver.\n", driver); printf("Running with the second stream as slave to the first.\n"); printf("\n"); /* Set up first stream */ plsetopt("geometry", geometry_master); plsdev(driver); plssub(2, 2); plinit(); /* Start next stream */ plsstrm(1); /* Turn off pause to make this a slave (must follow master) */ plsetopt("geometry", geometry_slave); plspause(0); plsdev(driver); plinit(); /* Set up the data & plot */ /* Original case */ plsstrm(0); xscale = 6.; yscale = 1.; xoff = 0.; yoff = 0.; plot1(); /* Set up the data & plot */ xscale = 1.; yscale = 1.e+6; plot1(); /* Set up the data & plot */ xscale = 1.; yscale = 1.e-6; digmax = 2; plsyax(digmax, 0); plot1(); /* Set up the data & plot */ xscale = 1.; yscale = 0.0014; yoff = 0.0185; digmax = 5; plsyax(digmax, 0); plot1(); /* To slave */ /* The pleop() ensures the eop indicator gets lit. */ plsstrm(1); plot4(); pleop(); /* Back to master */ plsstrm(0); plot2(); plot3(); /* To slave */ plsstrm(1); plot5(); pleop(); /* Back to master to wait for user to advance */ plsstrm(0); pleop(); /* Call plend to finish off. */ plend(); exit(0); }
void write_tasks(transport::repository<DataType>& repo, transport::gelaton_mpi<DataType, StateType>* model) { const double M_P = 1.0; const double P_zeta = 1E-9; // desired amplitude of fluctuations const double omega = M_PI / 30.0; // try to get round pi radians in ~ 30 e-folds const double V0 = 0.1 * P_zeta * M_P*M_P*M_P*M_P; // adjust uplift to get sufficient inflation const double eta_R = 1.0/std::sqrt(3.0); // adjust radial mass to be of order Hubble const double g_R = M_P*M_P / std::sqrt(V0); // adjust radial cubic coupling to be of order Hubble const double lambda_R = 0.5 * M_P*M_P*M_P / std::pow(V0, 3.0/4.0) / std::sqrt(omega); // adjust radial quartic coupling to dominate the displacement const double alpha = 7.25*omega; // adjust angular tilt to get desired omega const double R0 = std::sqrt(V0/3.0) / (M_P * omega * std::sqrt(P_zeta)); // adjust radial minimum to give desired P_zeta normalization const double x_init = -R0; const double y_init = (1E-2)*R0; const double R_init = std::sqrt(x_init*x_init + y_init*y_init); const double theta_init = std::atan2(y_init, x_init); const double N_init = 0.0; const double N_pre = 8.0; const double N_max = 28.0; transport::parameters<DataType> params{M_P, { R0, V0, eta_R, g_R, lambda_R, alpha }, model}; transport::initial_conditions<DataType> ics{"gelaton", params, { R_init, theta_init, 0.0, 0.0 }, N_init, N_pre}; transport::basic_range<double> times{N_init, N_max, 500, transport::spacing::linear}; transport::basic_range<double> ks{exp(10.0), exp(18.5), 1000, transport::spacing::log_bottom}; transport::basic_range<double> kts{exp(10.0), exp(17.0), 100, transport::spacing::log_bottom}; transport::basic_range<double> alphas{0.0, 0.0, 0, transport::spacing::linear}; transport::basic_range<double> betas{1.0/3.0, 1.0/3.0, 0, transport::spacing::linear}; // construct a twopf task transport::twopf_task<DataType> tk2{"gelaton.twopf", ics, times, ks}; tk2.set_collect_initial_conditions(true).set_adaptive_ics_efolds(5.0); // construct a threepf task transport::threepf_alphabeta_task<DataType> tk3{"gelaton.threepf", ics, times, kts, alphas, betas}; tk3.set_collect_initial_conditions(true).set_adaptive_ics_efolds(5.0); transport::zeta_twopf_task<DataType> ztk2{"gelaton.twopf-zeta", tk2}; transport::zeta_threepf_task<DataType> ztk3{"gelaton.threepf-zeta", tk3}; ztk2.set_paired(true); ztk3.set_paired(true); vis_toolkit::SQL_time_query tquery{"1=1"}; vis_toolkit::SQL_time_query tlast{"serial IN (SELECT MAX(serial) FROM time_samples)"}; vis_toolkit::SQL_twopf_query k2query{"comoving IN (SELECT MAX(comoving) FROM twopf_samples UNION SELECT MIN(comoving) FROM twopf_samples)"}; vis_toolkit::SQL_threepf_query k3query{"kt_comoving IN (SELECT MAX(kt_comoving) FROM threepf_samples UNION SELECT MIN(kt_comoving) FROM threepf_samples)"}; vis_toolkit::SQL_twopf_query k2all{"1=1"}; vis_toolkit::SQL_threepf_query k3all("1=1"); vis_toolkit::zeta_twopf_time_series<DataType> z2pf{ztk3, tquery, k2query}; // defaults to dimensionless vis_toolkit::largest_u2_line<DataType> u2line{tk3, tquery, k2query}; vis_toolkit::largest_u3_line<DataType> u3line{tk3, tquery, k3query}; vis_toolkit::background_line<DataType> hubble{tk3, tquery, vis_toolkit::background_quantity::Hubble}; vis_toolkit::index_selector<2> f2_fields{model->get_N_fields()}; f2_fields.none().set_on({0,0}).set_on({0,1}).set_on({1,0}).set_on({1,1}); vis_toolkit::index_selector<2> f2_momenta{model->get_N_fields()}; f2_momenta.none().set_on({2,2}).set_on({2,3}).set_on({3,2}).set_on({3,3}); vis_toolkit::index_selector<2> f2_cross{model->get_N_fields()}; f2_cross.none().set_on({2,0}).set_on({2,1}).set_on({3,0}).set_on({3,1}); vis_toolkit::index_selector<2> f2_cross2{model->get_N_fields()}; f2_cross2.none().set_on({0,2}).set_on({1,2}).set_on({0,3}).set_on({1,3}); vis_toolkit::twopf_time_series<DataType> tk2_fields{tk2, f2_fields, tquery, k2query}; vis_toolkit::twopf_time_series<DataType> tk2_momenta{tk2, f2_momenta, tquery, k2query}; vis_toolkit::twopf_time_series<DataType> tk2_cross{tk2, f2_cross, tquery, k2query}; vis_toolkit::twopf_time_series<DataType> tk2_cross2{tk2, f2_cross2, tquery, k2query}; vis_toolkit::time_series_plot<DataType> tk2_fplot{"gelaton.twopf-1.fields-plot", "fields-plot.pdf"}; tk2_fplot += tk2_fields; vis_toolkit::time_series_plot<DataType> tk2_mplot{"gelaton.twopf-1.momenta-plot", "momenta-plot.pdf"}; tk2_mplot += tk2_momenta; vis_toolkit::time_series_plot<DataType> tk2_cplot("gelaton.twopf-1.cross-plot", "cross-plot.pdf"); tk2_cplot += tk2_cross; vis_toolkit::time_series_plot<DataType> tk2_c2plot("gelaton.twopf-1.cross2-plot", "cross2-plot.pdf"); tk2_c2plot += tk2_cross2; vis_toolkit::u2_line<DataType> tk2_u2_fields{tk2, f2_fields, tquery, k2query}; vis_toolkit::u2_line<DataType> tk2_u2_momenta{tk2, f2_momenta, tquery, k2query}; vis_toolkit::u2_line<DataType> tk2_u2_cross{tk2, f2_cross, tquery, k2query}; vis_toolkit::u2_line<DataType> tk2_u2_cross2{tk2, f2_cross2, tquery, k2query}; vis_toolkit::time_series_plot<DataType> tk2_u2_mplot{"gelaton.twopf-1.u2-momenta-plot", "u2-momenta-plot.pdf"}; tk2_u2_mplot += tk2_u2_momenta; vis_toolkit::time_series_plot<DataType> tk2_u2_cplot{"gelaton.twopf-1.u2-cross-plot", "u2-cross-plot.pdf"}; tk2_u2_cplot += tk2_u2_cross; vis_toolkit::time_series_plot<DataType> tk2_u2_c2plot{"gelaton.twopf-1.u2-cross2-plot", "u2-cross2-plot.pdf"}; tk2_u2_c2plot += tk2_u2_cross2; vis_toolkit::time_series_table<DataType> tk2_u2_table{"gelaton.twopf-1.u2-table", "u2-table.txt"}; tk2_u2_table += tk2_u2_fields + tk2_u2_momenta + tk2_u2_cross + tk2_u2_cross2; vis_toolkit::index_selector<1> Rindex{model->get_N_fields()}; Rindex.none().set_on({0}); vis_toolkit::index_selector<1> thetaindex{model->get_N_fields()}; thetaindex.none().set_on({1}); vis_toolkit::background_time_series<DataType> tk2_R{tk2, Rindex, tquery}; vis_toolkit::background_time_series<DataType> tk2_theta{tk2, thetaindex, tquery}; vis_toolkit::background_line<DataType> tk2_eps{tk2, tquery, vis_toolkit::background_quantity::epsilon}; vis_toolkit::background_line<DataType> tk2_H{tk2, tquery, vis_toolkit::background_quantity::Hubble}; vis_toolkit::time_series_plot<DataType> tk2_R_plot{"gelaton.twopf-1.bg-R", "bg-R.pdf"}; tk2_R_plot += tk2_R; vis_toolkit::time_series_plot<DataType> tk2_theta_plot{"gelaton.twopf-1.bg-theta", "bg-theta.pdf"}; tk2_theta_plot += tk2_theta; vis_toolkit::time_series_plot<DataType> tk2_eps_plot{"gelaton.twopf-1.epsilon", "epsilon.pdf"}; tk2_eps_plot += tk2_eps; vis_toolkit::time_series_plot<DataType> tk2_H_plot{"gelaton.twopf-1.Hubble", "Hubble.pdf"}; tk2_H_plot += tk2_H; vis_toolkit::time_series_table<DataType> tk2_bg_table{"gelaton.twopf-1.bg-table", "bg-table.txt"}; tk2_bg_table += tk2_R + tk2_theta + tk2_eps + tk2_H; transport::output_task<DataType> tk2_out{"gelaton.test"}; tk2_out += tk2_fplot + tk2_mplot + tk2_cplot + tk2_c2plot + tk2_u2_mplot + tk2_u2_cplot + tk2_u2_c2plot + tk2_u2_table + tk2_R_plot + tk2_theta_plot + tk2_eps_plot + tk2_H_plot + tk2_bg_table; repo.commit(tk2_out); vis_toolkit::time_series_table<DataType> table{"gelaton.utable", "utable.txt"}; table += z2pf + u2line + u3line + hubble; vis_toolkit::zeta_twopf_wavenumber_series<DataType> zeta2pf{ztk3, tlast, k2all}; zeta2pf.set_current_x_axis_value(vis_toolkit::axis_value::efolds_exit); vis_toolkit::wavenumber_series_plot<DataType> zeta2pf_plot{"gelaton.threepf-1.zeta_2pf", "zeta2pf-plot.pdf"}; zeta2pf_plot += zeta2pf; vis_toolkit::index_selector<3> fsel{model->get_N_fields()}; fsel.none().set_on({0,0,0}).set_on({1,1,1}); vis_toolkit::threepf_time_series<DataType> tpf{tk3, fsel, tquery, k3query}; vis_toolkit::time_series_plot<DataType> plot{"gelaton.threepf-fields", "threepf-fields.pdf"}; plot += tpf; vis_toolkit::zeta_twopf_time_series<DataType> ztwpf{ztk3, tquery, k2query}; vis_toolkit::zeta_threepf_time_series<DataType> zthpf{ztk3, tquery, k3query}; vis_toolkit::zeta_reduced_bispectrum_time_series<DataType> zrbsp(ztk3, tquery, k3query); vis_toolkit::time_series_plot<DataType> plot2{"gelaton.threepf-zeta", "threepf-zeta.pdf"}; plot2 += zthpf; vis_toolkit::time_series_plot<DataType> plot2a{"gelaton.twopf-zeta", "twopf-zeta.pdf"}; plot2a += ztwpf; vis_toolkit::time_series_plot<DataType> plot3("gelaton.threepf-redbsp", "threepf-redbsp.pdf"); plot3.set_log_y(false); plot3 += zrbsp; vis_toolkit::time_series_table<DataType> thpf_tab{"gelaton.threepf-table", "threepf-table.txt"}; thpf_tab += ztwpf + zthpf + zrbsp; vis_toolkit::twopf_time_series<DataType> tk3_fields{tk3, f2_fields, tquery, k2query}; vis_toolkit::twopf_time_series<DataType> tk3_momenta{tk3, f2_momenta, tquery, k2query}; vis_toolkit::twopf_time_series<DataType> tk3_cross{tk3, f2_cross, tquery, k2query}; vis_toolkit::twopf_time_series<DataType> tk3_cross2{tk3, f2_cross2, tquery, k2query}; vis_toolkit::time_series_plot<DataType> tk3_fplot{"gelaton.threepf-1.fields-plot", "fields-plot.pdf"}; tk3_fplot += tk3_fields; vis_toolkit::time_series_plot<DataType> tk3_mplot{"gelaton.threepf-1.momenta-plot", "momenta-plot.pdf"}; tk3_mplot += tk3_momenta; vis_toolkit::time_series_plot<DataType> tk3_cplot{"gelaton.threepf-1.cross-plot", "cross-plot.pdf"}; tk3_cplot += tk3_cross; vis_toolkit::time_series_plot<DataType> tk3_c2plot{"gelaton.threepf-1.cross2-plot", "cross2-plot.pdf"}; tk3_c2plot += tk3_cross2; vis_toolkit::zeta_reduced_bispectrum_wavenumber_series<DataType> fNL{ztk3, tlast, k3all}; fNL.set_current_x_axis_value(vis_toolkit::axis_value::efolds_exit); vis_toolkit::wavenumber_series_plot<DataType> fNLplot{"gelaton.fNL", "fNL.pdf"}; fNLplot.set_log_y(false); fNLplot += fNL; transport::output_task<DataType> otk{"gelaton.output"}; otk += zeta2pf_plot + table + plot + plot2 + plot2a + plot3 + tk3_fplot + tk3_mplot + tk3_cplot + tk3_c2plot + thpf_tab + fNLplot; repo.commit(ztk2); repo.commit(ztk3); repo.commit(otk); }