mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add lines module and Line2D class
This commit is contained in:
parent
5364bc713a
commit
a2c056dde6
@ -120,6 +120,30 @@ public class ShapeUtil {
|
||||
|
||||
return shapes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a polyline shape
|
||||
*
|
||||
* @param x X coordinates
|
||||
* @param y Y coordinates
|
||||
* @return Polyline shape
|
||||
*/
|
||||
public static PolylineShape createPolylineShape(Array x, Array y) {
|
||||
double xx, yy;
|
||||
List<PointD> points = new ArrayList<>();
|
||||
PolylineShape pls;
|
||||
IndexIterator xIter = x.getIndexIterator();
|
||||
IndexIterator yIter = y.getIndexIterator();
|
||||
while (xIter.hasNext()){
|
||||
xx = xIter.getDoubleNext();
|
||||
yy = yIter.getDoubleNext();
|
||||
points.add(new PointD(xx, yy));
|
||||
}
|
||||
pls = new PolylineShape();
|
||||
pls.setPoints(points);
|
||||
|
||||
return pls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create polyline shapes
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\geotiff">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\special"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\topology">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\maskout"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\ascii"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
@ -16,15 +14,19 @@
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\geotiff"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\topology"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf_sombrero.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\geotiff\geotiff_dem.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\topology\difference_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\topology\buffer_1.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf_sombrero.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\geotiff\geotiff_dem.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\topology\difference_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\topology\buffer_1.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Binary file not shown.
@ -7,8 +7,10 @@ from ._axes3dgl import Axes3DGL
|
||||
from ._figure import Figure
|
||||
from ._glfigure import GLFigure
|
||||
from .patches import *
|
||||
from .lines import *
|
||||
|
||||
|
||||
__all__ = ['Figure','GLFigure','Axes','PolarAxes','MapAxes','Axes3D','Axes3DGL']
|
||||
__all__ += miplot.__all__
|
||||
__all__ += patches.__all__
|
||||
__all__ += patches.__all__
|
||||
__all__ += lines.__all__
|
||||
38
meteoinfo-lab/pylib/mipylib/plotlib/lines.py
Normal file
38
meteoinfo-lab/pylib/mipylib/plotlib/lines.py
Normal file
@ -0,0 +1,38 @@
|
||||
from org.meteoinfo.geometry.graphic import Graphic
|
||||
from org.meteoinfo.geometry.shape import ShapeUtil
|
||||
|
||||
from . import plotutil
|
||||
import mipylib.numeric as np
|
||||
|
||||
__all__ = ['Line2D']
|
||||
|
||||
class Line2D(Graphic):
|
||||
"""
|
||||
A line - the line can have both a solid linestyle connecting all the vertices, and a marker
|
||||
at each vertex.
|
||||
"""
|
||||
|
||||
def __init__(self, xdata, ydata, **kwargs):
|
||||
"""
|
||||
Create a `.Line2D` instance with *x* and *y* data in sequences of
|
||||
*xdata*, *ydata*.
|
||||
|
||||
:param xdata: (*array_like*) X data of the line.
|
||||
:param ydata: (*array_like*) Y data of the line.
|
||||
"""
|
||||
xdata = np.asarray(xdata)
|
||||
ydata = np.asarray(ydata)
|
||||
|
||||
self._xdata = xdata
|
||||
self._ydata = ydata
|
||||
shape = ShapeUtil.createPolylineShape(xdata._array, ydata._array)
|
||||
legend, isunique = plotutil.getlegendbreak('line', **kwargs)
|
||||
super(Line2D, self).__init__(shape, legend)
|
||||
|
||||
@property
|
||||
def xdata(self):
|
||||
return self._xdata
|
||||
|
||||
@property
|
||||
def ydata(self):
|
||||
return self._ydata
|
||||
@ -8,5 +8,5 @@
|
||||
<ScriptLanguage Language="Jython"/>
|
||||
<LookFeel LafDecorated="true" Name="FlatLightLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,693" ShowMeteoDataDlg="true"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,693" ShowMeteoDataDlg="false"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user