bugfix of imshow function

This commit is contained in:
wyq 2024-05-06 11:30:36 +08:00
parent 445c6879db
commit 151211d7a3
12 changed files with 49 additions and 61 deletions

View File

@ -685,7 +685,7 @@ public class ChartText extends Shape {
public void draw(Graphics2D g, float x, float y) { public void draw(Graphics2D g, float x, float y) {
Dimension dim = this.getDimension(g); Dimension dim = this.getDimension(g);
x += this.xShift; x += this.xShift;
y += this.yShift; y -= this.yShift;
AffineTransform tempTrans = g.getTransform(); AffineTransform tempTrans = g.getTransform();
if (this.angle != 0) { if (this.angle != 0) {

View File

@ -1,10 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile"> <MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\scatter"> <Path OpenPath="D:\Working\MIScript\Jython\mis\chart\text">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\fitting"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
@ -13,20 +9,26 @@
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\text"/>
</Path> </Path>
<File> <File>
<OpenedFiles> <OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\geoshow\geoshow_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_grid.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_grid.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\satellite\FY\FY4A_DSD_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\satellite\FY\FY4A_AGRI_CIX_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\chart\text\text_align_axesm.py"/>
</OpenedFiles> </OpenedFiles>
<RecentFiles> <RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\map\geoshow\geoshow_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume\plot_cuace_3d_volume.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_grid.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_grid.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\satellite\FY\FY4A_DSD_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\satellite\FY\FY4A_AGRI_CIX_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\chart\text\text_align_axesm.py"/>
</RecentFiles> </RecentFiles>
</File> </File>
<Font> <Font>
@ -34,5 +36,5 @@
</Font> </Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/> <LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/> <Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/> <Startup MainFormLocation="35,0" MainFormSize="1334,786"/>
</MeteoInfo> </MeteoInfo>

View File

@ -285,7 +285,7 @@ class Axes(object):
else: else:
return self._axes.getTitle() return self._axes.getTitle()
def set_title(self, label, loc='center', fontname=None, fontsize=14, bold=True, color='black', **kwargs): def set_title(self, label, loc='center', **kwargs):
""" """
Set a title of the current axes. Set a title of the current axes.
@ -298,24 +298,11 @@ class Axes(object):
:param color: (*color*) Title string color. Default is ``black`` . :param color: (*color*) Title string color. Default is ``black`` .
:param linespace: (*int*) Line space of multiple line title. :param linespace: (*int*) Line space of multiple line title.
""" """
exfont = False if not kwargs.has_key('bold'):
if fontname is None: kwargs['bold'] = True
fontname = 'Arial' if not kwargs.has_key('xalign'):
else: kwargs['xalign'] = 'center'
exfont = True title = plotutil.text(0, 0, label, **kwargs)
if bold:
font = Font(fontname, Font.BOLD, fontsize)
else:
font = Font(fontname, Font.PLAIN, fontsize)
c = plotutil.getcolor(color)
title = ChartText(label, font)
title.setXAlign(loc)
title.setUseExternalFont(exfont)
title.setColor(c)
linespace = kwargs.pop('linespace', None)
if not linespace is None:
title.setLineSpace(linespace)
if loc == 'left': if loc == 'left':
self._axes.setLeftTitle(title) self._axes.setLeftTitle(title)

View File

@ -712,7 +712,7 @@ class GLFigure(GLChartPanel, _FigureBase):
""" """
return self.getChart().getTitle() return self.getChart().getTitle()
def set_title(self, label, fontname=None, fontsize=14, bold=True, color='black'): def set_title(self, label, **kwargs):
""" """
Add a centered title to the figure. Add a centered title to the figure.
@ -722,21 +722,11 @@ class GLFigure(GLChartPanel, _FigureBase):
:param bold: (*boolean*) Is bold font or not. Default is ``True`` . :param bold: (*boolean*) Is bold font or not. Default is ``True`` .
:param color: (*color*) Title string color. Default is ``black`` . :param color: (*color*) Title string color. Default is ``black`` .
""" """
exfont = False if not kwargs.has_key('bold'):
if fontname is None: kwargs['bold'] = True
fontname = 'Arial' if not kwargs.has_key('xalign'):
else: kwargs['xalign'] = 'center'
exfont = True ctitle = plotutil.text(0, 0, label, **kwargs)
if bold:
font = Font(fontname, Font.BOLD, fontsize)
else:
font = Font(fontname, Font.PLAIN, fontsize)
c = plotutil.getcolor(color)
ctitle = ChartText(label, font)
ctitle.setXAlign('center')
ctitle.setUseExternalFont(exfont)
ctitle.setColor(c)
self.getChart().setTitle(ctitle) self.getChart().setTitle(ctitle)
return ctitle return ctitle

View File

@ -840,7 +840,7 @@ class MapAxes(Axes):
# Create graphics # Create graphics
if a.ndim == 0: if a.ndim == 0:
#graphics = GraphicFactory.createPoints(x._array, y._array, ls.getLegendBreak(0)) #graphics = GraphicFactory.createPoints(x._array, y._array, ls.getLegendBreak(0))
graphics = Point2DCollection(x._array, y._array, legend=ls.getLegendBreaks(0)) graphics = Point2DCollection(x._array, y._array, legend=ls.getLegendBreak(0))
else: else:
#graphics = GraphicFactory.createPoints(x._array, y._array, a._array, ls) #graphics = GraphicFactory.createPoints(x._array, y._array, a._array, ls)
graphics = Point2DCollection(x._array, y._array, a._array, ls) graphics = Point2DCollection(x._array, y._array, a._array, ls)
@ -1008,7 +1008,7 @@ class MapAxes(Axes):
:param x: (*array_like*) Optional. X coordinate array. :param x: (*array_like*) Optional. X coordinate array.
:param y: (*array_like*) Optional. Y coordinate array. :param y: (*array_like*) Optional. Y coordinate array.
:param z: (*array_like*) 2-D z value array. :param z: (*array_like*) 2-D z value array.
:param levs: (*array_like*) Optional. A list of floating point numbers indicating the level curves :param levels: (*array_like*) Optional. A list of floating point numbers indicating the level curves
to draw, in increasing order. to draw, in increasing order.
:param cmap: (*string*) Color map string. :param cmap: (*string*) Color map string.
:param colors: (*list*) If None (default), the colormap specified by cmap will be used. If a :param colors: (*list*) If None (default), the colormap specified by cmap will be used. If a
@ -1023,7 +1023,6 @@ class MapAxes(Axes):
:returns: (*RasterLayer*) RasterLayer created from array data. :returns: (*RasterLayer*) RasterLayer created from array data.
""" """
cmap = plotutil.getcolormap(**kwargs)
fill_value = kwargs.pop('fill_value', -9999.0) fill_value = kwargs.pop('fill_value', -9999.0)
ls = kwargs.pop('symbolspec', None) ls = kwargs.pop('symbolspec', None)
n = len(args) n = len(args)
@ -1095,6 +1094,8 @@ class MapAxes(Axes):
if ls is None: if ls is None:
vmin = kwargs.pop('vmin', arr.min()) vmin = kwargs.pop('vmin', arr.min())
vmax = kwargs.pop('vmax', arr.max()) vmax = kwargs.pop('vmax', arr.max())
has_colors = kwargs.has_key('colors')
cmap = plotutil.getcolormap(**kwargs)
if len(args) > 0: if len(args) > 0:
level_arg = args[0] level_arg = args[0]
if isinstance(level_arg, int): if isinstance(level_arg, int):
@ -1105,10 +1106,13 @@ class MapAxes(Axes):
level_arg = level_arg.aslist() level_arg = level_arg.aslist()
ls = LegendManage.createImageLegend(arr._array, level_arg, cmap) ls = LegendManage.createImageLegend(arr._array, level_arg, cmap)
else: else:
ls = plotutil.getlegendscheme(args, vmin, vmax, **kwargs) if has_colors:
norm = kwargs.pop('norm', colors.Normalize(vmin, vmax)) ls = LegendManage.createImageLegend(arr._array, cmap)
ls.setNormalize(norm._norm) else:
ls.setColorMap(cmap) ls = plotutil.getlegendscheme(args, vmin, vmax, cmap, **kwargs)
norm = kwargs.pop('norm', colors.Normalize(vmin, vmax))
ls.setNormalize(norm._norm)
ls.setColorMap(cmap)
plotutil.setlegendscheme(ls, **kwargs) plotutil.setlegendscheme(ls, **kwargs)
fill_color = kwargs.pop('fill_color', None) fill_color = kwargs.pop('fill_color', None)
if not fill_color is None: if not fill_color is None:

View File

@ -1209,15 +1209,15 @@ def clc():
@_copy_docstring_and_deprecators(Axes.set_title) @_copy_docstring_and_deprecators(Axes.set_title)
def title(label, loc='center', fontname=None, fontsize=14, bold=True, color='black', **kwargs): def title(label, loc='center', **kwargs):
r = g_axes.set_title(label, loc, fontname, fontsize, bold, color, **kwargs) r = g_axes.set_title(label, loc, **kwargs)
draw_if_interactive() draw_if_interactive()
return r return r
@_copy_docstring_and_deprecators(Figure.set_title) @_copy_docstring_and_deprecators(Figure.set_title)
def suptitle(label, fontname=None, fontsize=14, bold=True, color='black'): def suptitle(label, **kwargs):
r = g_figure.set_title(label, fontname, fontsize, bold, color) r = g_figure.set_title(label, **kwargs)
draw_if_interactive() draw_if_interactive()
return r return r

View File

@ -620,13 +620,14 @@ def getlegendbreak(geometry, **kwargs):
return lb, isunique return lb, isunique
def getlegendscheme(args, min, max, **kwargs): def getlegendscheme(args, min, max, cmap=None, **kwargs):
ls = kwargs.pop('symbolspec', None) ls = kwargs.pop('symbolspec', None)
if ls is None: if ls is None:
extend = kwargs.pop('extend', None) extend = kwargs.pop('extend', None)
if extend is not None: if extend is not None:
extend = ExtendType.valueOf(extend.upper()) extend = ExtendType.valueOf(extend.upper())
cmap = getcolormap(**kwargs) if cmap is None:
cmap = getcolormap(**kwargs)
level_arg = kwargs.pop('levels', None) level_arg = kwargs.pop('levels', None)
if level_arg is None and len(args) > 0: if level_arg is None and len(args) > 0:
level_arg = args[0] level_arg = args[0]
@ -1069,6 +1070,10 @@ def text(x, y, s, **kwargs):
yalign = kwargs.pop('yalign', None) yalign = kwargs.pop('yalign', None)
if not yalign is None: if not yalign is None:
text.setYAlign(yalign) text.setYAlign(yalign)
linespace = kwargs.pop('linespace', None)
if not linespace is None:
text.setLineSpace(linespace)
bbox = kwargs.pop('bbox', None) bbox = kwargs.pop('bbox', None)
if not bbox is None: if not bbox is None:
fill = bbox.pop('fill', None) fill = bbox.pop('fill', None)