diff --git a/Code/Mantid/MantidPlot/src/Graph.cpp b/Code/Mantid/MantidPlot/src/Graph.cpp index 47e6b3235c014d05e45d505a7e361589e0ac4c2f..bc2f85db81f72a10036fb8b91c2c24966108e8ad 100644 --- a/Code/Mantid/MantidPlot/src/Graph.cpp +++ b/Code/Mantid/MantidPlot/src/Graph.cpp @@ -61,6 +61,7 @@ #include "MantidAPI/AnalysisDataService.h" #include "Mantid/MantidMatrixCurve.h" #include "MantidQtAPI/PlotAxis.h" +#include "MantidQtAPI/QwtRasterDataMD.h" #include "MantidQtAPI/QwtWorkspaceSpectrumData.h" #include "Mantid/ErrorBarSettings.h" @@ -3074,6 +3075,35 @@ void Graph::updateScale() updateSecondaryAxis(QwtPlot::yRight); } + auto mantidCurve = dynamic_cast<MantidCurve*>(curve(0)); + auto dataCurve = dynamic_cast<DataCurve*>(curve(0)); + + if (mantidCurve) + { + setXAxisTitle(mantidCurve->mantidData()->getXAxisLabel()); + setYAxisTitle(mantidCurve->mantidData()->getYAxisLabel()); + } + else if (dataCurve && dataCurve->table()) + { + setXAxisTitle(dataCurve->table()->colLabel(0)); + setYAxisTitle(dataCurve->table()->colLabel(1).section(".",0,0)); + } + + Spectrogram* spec = spectrogram(); + if (spec) + { + auto specData = dynamic_cast<const MantidQt::API::QwtRasterDataMD*>(&spec->data()); + if (specData) + { + Mantid::API::IMDWorkspace_const_sptr ws = specData->getWorkspace(); + if(ws) + { + setXAxisTitle(MantidQt::API::PlotAxis(*ws, 0).title()); + setYAxisTitle(MantidQt::API::PlotAxis(*ws, 1).title()); + } + } + } + d_plot->replot();//TODO: avoid 2nd replot! d_zoomer[0]->setZoomBase(false); } diff --git a/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp b/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp index 80a11e9aa86075b78062b80f29a104fe54340780..5dd11e651811c3c146509769838d870c18003433 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp @@ -617,11 +617,7 @@ MultiLayer* MantidUI::plotMDList(const QStringList& wsNames, const int plotAxis, // Using information from the first graph if( i == 0 && isGraphNew ) - { - g->setXAxisTitle(data->getXAxisLabel()); - g->setYAxisTitle(data->getYAxisLabel()); g->setAutoScale(); - } } } @@ -2770,8 +2766,6 @@ void MantidUI::importNumSeriesLog(const QString &wsName, const QString &logName, g->setCurvePen(iFilterCurve, pn); } } - g->setXAxisTitle(t->colLabel(0)); - g->setYAxisTitle(t->colLabel(1).section(".",0,0)); g->setTitle(label); g->setAutoScale(); @@ -2994,8 +2988,6 @@ void MantidUI::setUpBinGraph(MultiLayer* ml, const QString& Name, Mantid::API::M { xtitle = MantidQt::API::PlotAxis(*workspace, 1).title(); } - g->setXAxisTitle(xtitle); - g->setYAxisTitle(MantidQt::API::PlotAxis(false, *workspace).title()); } /** @@ -3221,8 +3213,6 @@ MultiLayer* MantidUI::plot1D(const QMultiMap<QString,int>& toPlot, bool spectrum return NULL; } - g->setXAxisTitle(firstCurve->mantidData()->getXAxisLabel()); - g->setYAxisTitle(firstCurve->mantidData()->getYAxisLabel()); g->setAutoScale(); /* The 'setAutoScale' above is needed to make sure that the plot initially encompasses all the * data points. However, this has the side-effect suggested by its name: all the axes become @@ -3404,9 +3394,6 @@ MultiLayer* MantidUI::drawSingleColorFillPlot(const QString & wsName, Graph::Cur appWindow()->setPreferences(plot); plot->setTitle(wsName); - using MantidQt::API::PlotAxis; - plot->setXAxisTitle(PlotAxis(*workspace, 0).title()); - plot->setYAxisTitle(PlotAxis(*workspace, 1).title()); Spectrogram *spgrm = new Spectrogram(wsName, workspace); plot->plotSpectrogram(spgrm, curveType);