mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
bugfix for Line2D to ignore nan data
This commit is contained in:
parent
1756071468
commit
869ecb9169
@ -1475,6 +1475,10 @@ public class Axis extends Artist implements Cloneable {
|
||||
//Draw tick lines
|
||||
float len = 0;
|
||||
if (this.drawTickLine) {
|
||||
if (this.getTickValues() == null) {
|
||||
this.updateTickValues();
|
||||
}
|
||||
|
||||
g.setColor(this.tickColor);
|
||||
g.setStroke(new BasicStroke(this.tickWidth));
|
||||
g.setFont(this.tickLabelFont);
|
||||
@ -1706,6 +1710,10 @@ public class Axis extends Artist implements Cloneable {
|
||||
//Draw tick lines
|
||||
float len = 0;
|
||||
if (this.drawTickLine) {
|
||||
if (this.getTickValues() == null) {
|
||||
this.updateTickValues();
|
||||
}
|
||||
|
||||
g.setColor(this.getTickColor());
|
||||
g.setStroke(new BasicStroke(this.tickWidth));
|
||||
g.setFont(this.getTickLabelFont());
|
||||
|
||||
@ -74,8 +74,14 @@ public class Line2DGraphic extends Graphic {
|
||||
List<PointD> points = new ArrayList<>();
|
||||
IndexIterator xIter = this.xData.getIndexIterator();
|
||||
IndexIterator yIter = this.yData.getIndexIterator();
|
||||
double x, y;
|
||||
while (xIter.hasNext()) {
|
||||
points.add(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext()));
|
||||
x = xIter.getDoubleNext();
|
||||
y = yIter.getDoubleNext();
|
||||
if (Double.isNaN(x) || Double.isNaN(y)) {
|
||||
continue;
|
||||
}
|
||||
points.add(new PointD(x, y));
|
||||
}
|
||||
if (this.shape == null) {
|
||||
this.shape = new PolylineShape();
|
||||
@ -90,10 +96,15 @@ public class Line2DGraphic extends Graphic {
|
||||
IndexIterator cIter = this.cData.getIndexIterator();
|
||||
ColorBreakCollection cbc = new ColorBreakCollection();
|
||||
ColorBreak cb;
|
||||
double c;
|
||||
double x, y, c;
|
||||
while (xIter.hasNext()) {
|
||||
points.add(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext()));
|
||||
x = xIter.getDoubleNext();
|
||||
y = yIter.getDoubleNext();
|
||||
c = cIter.getDoubleNext();
|
||||
if (Double.isNaN(x) || Double.isNaN(y)) {
|
||||
continue;
|
||||
}
|
||||
points.add(new PointD(x, y));
|
||||
cb = legendScheme.findLegendBreak(c);
|
||||
cbc.add(cb);
|
||||
}
|
||||
|
||||
@ -1,34 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\traj">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\json"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\plot">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\imshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\calc"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\MyProgram\java\MeteoInfoDev\MeteoInfo\meteoinfo-lab"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\funny\flower_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\calc\frontogenesis.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\traj\hy_part_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\traj\plot_basic.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_nan.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\funny\flower_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\calc\frontogenesis.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\traj\hy_part_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\traj\plot_basic.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_nan.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Binary file not shown.
@ -1227,8 +1227,10 @@ class Axes(object):
|
||||
:param x: (*array_like*) Input x data.
|
||||
:param y: (*array_like*) Input y data.
|
||||
:param style: (*string*) Line style for plot.
|
||||
:param linewidth: (*float*) Line width.
|
||||
:param color: (*Color*) Line color.
|
||||
|
||||
:returns: Legend breaks of the lines.
|
||||
:returns: lines.
|
||||
|
||||
The following format string characters are accepted to control the line style or marker:
|
||||
|
||||
@ -1273,27 +1275,22 @@ class Axes(object):
|
||||
xaxistype = None
|
||||
isxylistdata = False
|
||||
if len(args) == 1:
|
||||
if isinstance(args[0], MIXYListData):
|
||||
dataset = args[0].data
|
||||
snum = args[0].size()
|
||||
isxylistdata = True
|
||||
ydata = np.array(args[0])
|
||||
if isinstance(ydata, DimArray):
|
||||
xdata = ydata.dimvalue(0)
|
||||
if ydata.ndim == 2:
|
||||
xdata = ydata.dimvalue(1)
|
||||
xx = np.zeros(ydata.shape)
|
||||
xx[:, :] = xdata
|
||||
xdata = xx
|
||||
else:
|
||||
ydata = np.array(args[0])
|
||||
if isinstance(ydata, DimArray):
|
||||
xdata = ydata.dimvalue(0)
|
||||
if ydata.ndim == 2:
|
||||
xdata = ydata.dimvalue(1)
|
||||
xx = np.zeros(ydata.shape)
|
||||
xx[:, :] = xdata
|
||||
xdata = xx
|
||||
else:
|
||||
xdata = np.arange(ydata.shape[-1])
|
||||
if ydata.ndim == 2:
|
||||
xx = np.zeros(ydata.shape)
|
||||
xx[:, :] = xdata
|
||||
xdata = xx
|
||||
xdatalist.append(xdata)
|
||||
ydatalist.append(ydata)
|
||||
xdata = np.arange(ydata.shape[-1])
|
||||
if ydata.ndim == 2:
|
||||
xx = np.zeros(ydata.shape)
|
||||
xx[:, :] = xdata
|
||||
xdata = xx
|
||||
xdatalist.append(xdata)
|
||||
ydatalist.append(ydata)
|
||||
elif len(args) == 2:
|
||||
if isinstance(args[1], basestring):
|
||||
ydata = np.array(args[0])
|
||||
@ -1333,6 +1330,7 @@ class Axes(object):
|
||||
styles.append(None)
|
||||
xdatalist.append(arg)
|
||||
c = 'y'
|
||||
|
||||
if len(styles) == 0:
|
||||
styles = None
|
||||
else:
|
||||
@ -1411,49 +1409,49 @@ class Axes(object):
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
iscurve = kwargs.pop('curve', False)
|
||||
graphics = []
|
||||
if isxylistdata:
|
||||
graphic = GraphicFactory.createLineString(dataset, lines)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
if cdata is None:
|
||||
# Add data series
|
||||
snum = len(xdatalist)
|
||||
if snum == 1:
|
||||
xdata = np.asarray(xdatalist[0])
|
||||
ydata = np.asarray(ydatalist[0])
|
||||
if len(lines) == 1:
|
||||
colors = kwargs.pop('colors', None)
|
||||
if not colors is None:
|
||||
colors = plotutil.getcolors(colors)
|
||||
cb = lines[0]
|
||||
lines = []
|
||||
for cc in colors:
|
||||
ncb = cb.clone()
|
||||
ncb.setColor(cc)
|
||||
lines.append(ncb)
|
||||
graphic = GraphicFactory.createLineString(xdata._array, ydata._array, lines, iscurve)
|
||||
else:
|
||||
graphic = Line2D(xdata, ydata, legend=lines[0], curve=iscurve)
|
||||
else: # >1
|
||||
graphic = GraphicFactory.createLineString(xdata._array, ydata._array, lines, iscurve)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
for i in range(0, snum):
|
||||
label = kwargs.pop('label', 'S_' + str(i + 1))
|
||||
xdata = np.asarray(xdatalist[i])
|
||||
ydata = np.asarray(ydatalist[i])
|
||||
graphic = Line2D(xdata, ydata, legend=lines[i], curve=iscurve)
|
||||
self.add_graphic(graphic)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
if cdata is None:
|
||||
# Add data series
|
||||
snum = len(xdatalist)
|
||||
if snum == 1:
|
||||
xdata = np.asarray(xdatalist[0])
|
||||
ydata = np.asarray(ydatalist[0])
|
||||
cdata = np.asarray(cdata)
|
||||
graphic = Line2D(xdata, ydata, legend=ls, cdata=cdata, curve=iscurve)
|
||||
if len(lines) == 1:
|
||||
colors = kwargs.pop('colors', None)
|
||||
if not colors is None:
|
||||
colors = plotutil.getcolors(colors)
|
||||
cb = lines[0]
|
||||
lines = []
|
||||
for cc in colors:
|
||||
ncb = cb.clone()
|
||||
ncb.setColor(cc)
|
||||
lines.append(ncb)
|
||||
graphic = GraphicFactory.createLineString(xdata._array, ydata._array, lines, iscurve)
|
||||
else:
|
||||
graphic = Line2D(xdata, ydata, legend=lines[0], curve=iscurve)
|
||||
else: # >1
|
||||
graphic = GraphicFactory.createLineString(xdata._array, ydata._array, lines, iscurve)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
for i in range(0, snum):
|
||||
label = kwargs.pop('label', 'S_' + str(i + 1))
|
||||
xdata = np.asarray(xdatalist[i])
|
||||
ydata = np.asarray(ydatalist[i])
|
||||
graphic = Line2D(xdata, ydata, legend=lines[i], curve=iscurve)
|
||||
self.add_graphic(graphic)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
xdata = np.asarray(xdatalist[0])
|
||||
ydata = np.asarray(ydatalist[0])
|
||||
cdata = np.asarray(cdata)
|
||||
graphic = Line2D(xdata, ydata, legend=ls, cdata=cdata, curve=iscurve)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
|
||||
antialias = kwargs.pop('antialias', None)
|
||||
if antialias is not None:
|
||||
for graphic in graphics:
|
||||
graphic.setAntiAlias(antialias)
|
||||
|
||||
if len(graphics) > 1:
|
||||
return graphics
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user