예제 #1
0
파일: gnuplot.cpp 프로젝트: mkrnc/snap
int TGnuPlot::AddPlot(const TIntFltPrV& XYValV, const TGpSeriesTy& SeriesTy, const TStr& Label, const TStr& Style) {
  TFltKdV XYFltValV(XYValV.Len(), 0);
  for (int i = 0; i < XYValV.Len(); i++) {
    XYFltValV.Add(TFltKd(TFlt(XYValV[i].Val1), TFlt(XYValV[i].Val2)));
  }
  return AddPlot(XYFltValV, SeriesTy, Label, Style);
}
vtkSmartPointer<vtkChartXY> chart_from_histogram(
    const THisto& input_histo, vtkIdType chart_type = vtkChart::LINE) {
  auto chart = vtkSmartPointer<vtkChartXY>::New();
  vtkNew<vtkTable> table;
  table->SetNumberOfRows(input_histo.bins);
  vtkNew<vtkFloatArray> xArray;
  xArray->SetName("Bins");
  xArray->SetNumberOfValues(input_histo.bins);
  table->AddColumn(xArray.GetPointer());
  vtkNew<vtkFloatArray> yArray;
  yArray->SetName("Counts");
  yArray->SetNumberOfValues(input_histo.bins);
  table->AddColumn(yArray.GetPointer());

  auto centers = input_histo.ComputeBinCenters();
  for(size_t j = 0; j != input_histo.bins; j++) {
    xArray->SetValue(j, centers[j]);
    yArray->SetValue(j, input_histo.counts[j]);
  }
  // auto const &xAxis = chart->GetAxis(vtkAxis::BOTTOM) ;
  // xAxis->SetRange(input_histo.range.first, input_histo.range.second);
  // xAxis->SetTitle(input_histo.name);
  // xAxis->SetBehavior(vtkAxis::FIXED);
  // chart->GetAxis(vtkAxis::LEFT)->SetBehavior(vtkAxis::FIXED);
  // chart->GetAxis(vtkAxis::BOTTOM)->SetBehavior(vtkAxis::FIXED);
  chart->GetAxis(vtkAxis::LEFT)->SetTitle("#");
  chart->GetAxis(vtkAxis::BOTTOM)->SetTitle("bins");
  chart->SetTitle(input_histo.name);
  auto points = chart->AddPlot(chart_type);
  points->SetInputData(table, 0, 1);
  return chart;
}
예제 #3
0
파일: gnuplot.cpp 프로젝트: mkrnc/snap
int TGnuPlot::AddPlot(const TFltV& YValV, const TGpSeriesTy& SeriesTy, const TStr& Label, const TStr& Style) {
  TFltKdV XYValV(YValV.Len(), 0);
  for (int i = 0; i < YValV.Len(); i++) {
    XYValV.Add(TFltKd(TFlt(i+1), TFlt(YValV[i])));
  }
  return AddPlot(XYValV, SeriesTy, Label, Style);
}
예제 #4
0
파일: gnuplot.cpp 프로젝트: mkrnc/snap
int TGnuPlot::AddErrBar(const TFltPrV& XYValV, const TFltV& DeltaV, const TStr& DatLabel, const TStr& ErrLabel) {
  TFltKdV XYFltValV(XYValV.Len(), 0);
  for (int i = 0; i < XYValV.Len(); i++) {
    XYFltValV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2));
  }
  const int PlotId = AddPlot(XYFltValV, gpwLinesPoints, DatLabel);
  AddErrBar(XYFltValV, DeltaV, ErrLabel);
  return PlotId;
}
예제 #5
0
파일: gnuplot.cpp 프로젝트: mkrnc/snap
int TGnuPlot::AddPlot(const TStr& DataFNm, const int& ColY,
                      const TGpSeriesTy& SeriesTy, const TStr& Label, const TStr& Style) {
  return AddPlot(DataFNm, 0, ColY, SeriesTy, Label, Style);
}
예제 #6
0
Plot::Plot(const Matrix &_data, int _cols[], const int &_numCols)
{
    Plot();
    AddPlot(_data, _cols, _numCols);
}
예제 #7
0
Plot::Plot(const Matrix &_data)
{
    Plot();
    AddPlot(_data);
    return;
}