mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] update polar plot
This commit is contained in:
parent
19289ccc4e
commit
b3ab5543dd
@ -25,17 +25,15 @@ __copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.pylab as lab
|
||||
from matplotlib.pyplot import figure
|
||||
import plotly as plt
|
||||
import plotly.graph_objs as go
|
||||
import numpy as np
|
||||
|
||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
||||
from processing.core.parameters import ParameterTable
|
||||
from processing.core.parameters import ParameterTableField
|
||||
from processing.core.outputs import OutputHTML
|
||||
from processing.tools import vector
|
||||
from processing.tools import dataobjects
|
||||
from processing.tools import dataobjects, vector
|
||||
|
||||
|
||||
class PolarPlot(GeoAlgorithm):
|
||||
@ -66,16 +64,8 @@ class PolarPlot(GeoAlgorithm):
|
||||
|
||||
output = self.getOutputValue(self.OUTPUT)
|
||||
|
||||
values = vector.values(layer, namefieldname, valuefieldname)
|
||||
plt.close()
|
||||
fig = figure(figsize=(8, 8))
|
||||
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
|
||||
N = len(values[valuefieldname])
|
||||
theta = np.arange(0.0, 2 * np.pi, 2 * np.pi / N)
|
||||
radii = values[valuefieldname]
|
||||
width = 2 * np.pi / N
|
||||
ax.bar(theta, radii, width=width, bottom=0.0)
|
||||
plotFilename = output + '.png'
|
||||
lab.savefig(plotFilename)
|
||||
with open(output, 'w') as f:
|
||||
f.write('<html><img src="' + plotFilename + '"/></html>')
|
||||
values = vector.values(layer, valuefieldname)
|
||||
|
||||
data = [go.Area(r=values[valuefieldname],
|
||||
t=np.degrees(np.arange(0.0, 2 * np.pi, 2 * np.pi / len(values[valuefieldname]))))]
|
||||
plt.offline.plot(data, filename=output)
|
||||
|
@ -262,31 +262,20 @@ 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
|
||||
|
||||
#~ 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
|
||||
from .PolarPlot import PolarPlot
|
||||
|
||||
self.alglist.extend([VectorLayerHistogram(), RasterLayerHistogram(),
|
||||
VectorLayerScatterplot(), MeanAndStdDevPlot(), BarPlot()])
|
||||
VectorLayerScatterplot(), MeanAndStdDevPlot(),
|
||||
BarPlot(), PolarPlot()])
|
||||
|
||||
self.externalAlgs = [] # to store algs added by 3rd party plugins as scripts
|
||||
# to store algs added by 3rd party plugins as scripts
|
||||
self.externalAlgs = []
|
||||
|
||||
folder = os.path.join(os.path.dirname(__file__), 'scripts')
|
||||
scripts = ScriptUtils.loadFromFolder(folder)
|
||||
|
Loading…
x
Reference in New Issue
Block a user