mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] update vector layer histogram
This commit is contained in:
parent
a352773887
commit
e0131a7526
@ -276,14 +276,16 @@ class QGISAlgorithmProvider(AlgorithmProvider):
|
||||
#~ 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 @@ __copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
__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 @@ class VectorLayerHistogram(GeoAlgorithm):
|
||||
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 @@ class VectorLayerScatterplot(GeoAlgorithm):
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user