Skip to content
Permalink
Browse files

[processing] update vector layer histogram

  • Loading branch information
alexbruy committed Feb 15, 2017
1 parent a352773 commit e0131a75263cb7e2b72e959f6c1d6073befb6413
@@ -276,14 +276,16 @@ def __init__(self):
#~ PolarPlot(),
#~ ])
if hasPlotly:
#~ from .VectorLayerHistogram import VectorLayerHistogram
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([VectorLayerScatterplot(), BarPlot()])
self.alglist.extend([
VectorLayerHistogram(), VectorLayerScatterplot(),
BarPlot()])

self.externalAlgs = [] # to store algs added by 3rd party plugins as scripts

@@ -25,8 +25,8 @@

__revision__ = '$Format:%H$'

import matplotlib.pyplot as plt
import matplotlib.pylab as lab
import plotly as plt
import plotly.graph_objs as go

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.parameters import ParameterVector
@@ -66,9 +66,7 @@ def processAlgorithm(self, feedback):
output = self.getOutputValue(self.OUTPUT)

values = vector.values(layer, fieldname)
plt.close()
plt.hist(values[fieldname], bins)
plotFilename = output + '.png'
lab.savefig(plotFilename)
with open(output, 'w') as f:
f.write('<html><img src="' + plotFilename + '"/></html>')

data = [go.Histogram(x=values[fieldname],
nbinsx=bins)]
plt.offline.plot(data, filename=output)
@@ -72,6 +72,5 @@ def processAlgorithm(self, feedback):
values = vector.values(layer, xfieldname, yfieldname)
data = [go.Scatter(x=values[xfieldname],
y=values[yfieldname],
mode='markers'
)]
mode='markers')]
plt.offline.plot(data, filename=output)

0 comments on commit e0131a7

Please sign in to comment.
You can’t perform that action at this time.