Skip to content

Commit

Permalink
Update the axis title when plotting distribution
Browse files Browse the repository at this point in the history
Refs #10639
  • Loading branch information
martyngigg committed Nov 28, 2014
1 parent 6f5555d commit 744ba2e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Code/Mantid/MantidPlot/src/Graph.cpp
Expand Up @@ -58,7 +58,9 @@
#include "ApplicationWindow.h"
#include "plot2D/ScaleEngine.h"

#include "MantidAPI/AnalysisDataService.h"
#include "Mantid/MantidMatrixCurve.h"
#include "MantidQtAPI/PlotAxis.h"
#include "MantidQtAPI/QwtWorkspaceSpectrumData.h"
#include "Mantid/ErrorBarSettings.h"

Expand Down Expand Up @@ -3813,6 +3815,22 @@ void Graph::addLegendItem()
}
}

QString Graph::yAxisTitleFromFirstCurve()
{
// I really don't like this...
if(auto *firstCurve = dynamic_cast<MantidMatrixCurve*>(curve(0)))
{
using namespace Mantid::API;
QString wsName = firstCurve->workspaceName();
auto ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName.toStdString());
return MantidQt::API::PlotAxis(m_isDistribution, *ws).title();
}
else
{
return axisTitle(0);
}
}

void Graph::contextMenuEvent(QContextMenuEvent *e)
{
if (selectedMarker>=0) {
Expand Down Expand Up @@ -5993,6 +6011,7 @@ void Graph::noNormalization()
m_isDistribution = false;
updateDataCurves();
d_plot->updateAxes();
setYAxisTitle(yAxisTitleFromFirstCurve());
notifyChanges();
}

Expand All @@ -6006,6 +6025,8 @@ void Graph::binWidthNormalization()
m_isDistribution = true;
updateDataCurves();
d_plot->updateAxes();
setYAxisTitle(yAxisTitleFromFirstCurve());

notifyChanges();
}

Expand Down
4 changes: 3 additions & 1 deletion Code/Mantid/MantidPlot/src/Graph.h
Expand Up @@ -826,7 +826,9 @@ private slots:
void niceLogScales(QwtPlot::Axis axis);
void deselectCurves();
void addLegendItem();


QString yAxisTitleFromFirstCurve();

Plot *d_plot;
QwtPlotZoomer *d_zoomer[2];
TitlePicker *titlePicker;
Expand Down

0 comments on commit 744ba2e

Please sign in to comment.