diff --git a/python/plugins/processing/algs/qgis/BarPlot.py b/python/plugins/processing/algs/qgis/BarPlot.py index 2b91441c12e..b8d9cf66846 100644 --- a/python/plugins/processing/algs/qgis/BarPlot.py +++ b/python/plugins/processing/algs/qgis/BarPlot.py @@ -25,8 +25,11 @@ __copyright__ = '(C) 2013, Victor Olaya' __revision__ = '$Format:%H$' -import matplotlib.pyplot as plt -import matplotlib.pylab as lab +#import matplotlib.pyplot as plt +#import matplotlib.pylab as lab + +import plotly as plt +import plotly.graph_objs as go import numpy as np from processing.core.parameters import ParameterTable @@ -69,13 +72,8 @@ class BarPlot(GeoAlgorithm): output = self.getOutputValue(self.OUTPUT) values = vector.values(layer, namefieldname, valuefieldname) - plt.close() ind = np.arange(len(values[namefieldname])) - width = 0.8 - plt.bar(ind, values[valuefieldname], width, color='r') - plt.xticks(ind, values[namefieldname], rotation=45) - plotFilename = output + '.png' - lab.savefig(plotFilename) - with open(output, 'w') as f: - f.write('') + data = [go.Bar(x=ind, + y=values[valuefieldname])] + plt.offline.plot(data, filename=output) diff --git a/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py b/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py index 14cdbfc4a08..76de2b84209 100644 --- a/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py +++ b/python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py @@ -28,11 +28,14 @@ __revision__ = '$Format:%H$' import os try: - import matplotlib.pyplot - assert matplotlib # NOQA silence pyflakes - hasMatplotlib = True + #import matplotlib.pyplot + #assert matplotlib # NOQA silence pyflakes + #hasMatplotlib = True + import plotly + hasPlotly = True except: - hasMatplotlib = False + #hasMatplotlib = False + hasPlotly = False from qgis.PyQt.QtGui import QIcon @@ -259,19 +262,28 @@ class QGISAlgorithmProvider(AlgorithmProvider): FixGeometry(), ExecuteSQL(), FindProjection() ] - if hasMatplotlib: - from .VectorLayerHistogram import VectorLayerHistogram - from .RasterLayerHistogram import RasterLayerHistogram - from .VectorLayerScatterplot import VectorLayerScatterplot - from .MeanAndStdDevPlot import MeanAndStdDevPlot - from .BarPlot import BarPlot - from .PolarPlot import PolarPlot + #~ if hasMatplotlib: + #~ from .VectorLayerHistogram import VectorLayerHistogram + #~ from .RasterLayerHistogram import RasterLayerHistogram + #~ from .VectorLayerScatterplot import VectorLayerScatterplot + #~ from .MeanAndStdDevPlot import MeanAndStdDevPlot + #~ from .BarPlot import BarPlot + #~ from .PolarPlot import PolarPlot - self.alglist.extend([ - VectorLayerHistogram(), RasterLayerHistogram(), - VectorLayerScatterplot(), MeanAndStdDevPlot(), BarPlot(), - PolarPlot(), - ]) + #~ self.alglist.extend([ + #~ VectorLayerHistogram(), RasterLayerHistogram(), + #~ VectorLayerScatterplot(), MeanAndStdDevPlot(), BarPlot(), + #~ PolarPlot(), + #~ ]) + if hasPlotly: + #~ from .VectorLayerHistogram import VectorLayerHistogram + #~ from .RasterLayerHistogram import RasterLayerHistogram + #~ from .VectorLayerScatterplot import VectorLayerScatterplot + #~ from .MeanAndStdDevPlot import MeanAndStdDevPlot + from .BarPlot import BarPlot + #~ from .PolarPlot import PolarPlot + + self.alglist.extend([BarPlot()]) self.externalAlgs = [] # to store algs added by 3rd party plugins as scripts