Я уже некоторое время использую wxWidgets - Mathplot, но у меня есть пара проблем. Кто-нибудь знает, как записать векторные данные на вторичную ось Y? Я создал 4 слоя для построения, взятых из 4 векторов. Код, который я использовал, строит все векторы на одной оси Y. Я хотел бы разделить их. Любая помощь будет оценена. Я добавил второй mpScaleY, но масштаб кажется идентичным основной оси Y.
График показан здесь
Вот код, который я написал:
void MathPlotWnd::createMathPlot()
{
auto* const vectorLayer = m_plotData.getVectorLayer();
auto* const vectorLayer2 = m_plotData.getVectorLayer2();
auto* const vectorLayer3 = m_plotData.getVectorLayer3();
auto* const vectorLayer4 = m_plotData.getVectorLayer4();
wxPen vectorpen(*wxBLUE, 2, wxSOLID);
wxPen vectorpen2(*wxGREEN, 2, wxSOLID);
wxPen vectorpen3(*wxRED, 2, wxSOLID);
wxPen vectorpen4(*wxLIGHT_GREY, 2, wxSOLID);
vectorLayer->SetContinuity(true);
vectorLayer->SetPen(vectorpen);
vectorLayer->SetDrawOutsideMargins(false);
vectorLayer2->SetContinuity(true);
vectorLayer2->SetPen(vectorpen2);
vectorLayer2->SetDrawOutsideMargins(false);
vectorLayer3->SetContinuity(true);
vectorLayer3->SetPen(vectorpen3);
vectorLayer3->SetDrawOutsideMargins(false);
vectorLayer4->SetContinuity(true);
vectorLayer4->SetPen(vectorpen4);
vectorLayer4->SetDrawOutsideMargins(false);
wxFont graphFont(11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
mpScaleX* xaxis = new mpScaleX(wxT("X"), mpALIGN_BOTTOM, true, mpX_NORMAL);
mpScaleY* yaxis1 = new mpScaleY(wxT("Y1"), mpALIGN_LEFT, true); //Primary y-axis
mpScaleY* yaxis2 = new mpScaleY(wxT("Y2"), mpALIGN_RIGHT, true); //Secondary y-axis
xaxis->SetFont(graphFont);
yaxis1->SetFont(graphFont);
xaxis->SetDrawOutsideMargins(false);
yaxis1->SetDrawOutsideMargins(false);
MathPlot->SetMargins(20,20,20,20);
MathPlot->AddLayer(xaxis);
MathPlot->AddLayer(yaxis1);
MathPlot->AddLayer(yaxis2);
MathPlot->AddLayer(vectorLayer);
MathPlot->AddLayer(vectorLayer2);
MathPlot->AddLayer(vectorLayer3);
MathPlot->AddLayer(vectorLayer4);
MathPlot->AddLayer(new mpText(wxT("mpText sample"), 10, 10));
wxBrush hatch(wxColour(200,200,200), wxSOLID);
MathPlot->AddLayer( nfo = new mpInfoCoords(wxRect(80,20,10,10), wxTRANSPARENT_BRUSH));
nfo->SetVisible(false);
wxBrush hatch2(wxColour(163,208,212), wxSOLID);
mpInfoLegend* leg;
MathPlot->AddLayer( leg = new mpInfoLegend(wxRect(200,10,20,20), wxTRANSPARENT_BRUSH)); //&hatch2));
leg->SetVisible(true);
wxPen mypen(*wxRED, 5, wxSOLID);
MathPlot->EnableDoubleBuffer(true);
MathPlot->SetMPScrollbars(false);
}
void MathPlotWnd::updateMathPlot()
{
m_plotData.getVectorLayer()->SetData(m_plotData.getTimeArray(), m_plotData.getArray1());
MathPlot->Fit();
m_plotData.getVectorLayer2()->SetData(m_plotData.getTimeArray(), m_plotData.getArray2());
MathPlot->Fit();
m_plotData.getVectorLayer3()->SetData(m_plotData.getTimeArray(), m_plotData.getArray3());
MathPlot->Fit();
m_plotData.getVectorLayer4()->SetData(m_plotData.getTimeArray(), m_plotData.gettArray4());
MathPlot->Fit();
}
'SetData' добавляет массивы к графику. Но я не могу найти способ добавить массив к 'yaxis2'. Он просто создает yaxis2 как дубликат yaxis1. Похоже, что нет команды, которая различала бы: 'plot array to yaxis1 или yaxis2'. Смотрите прикрепленный для изображения сюжета. Спасибо,
Пол