|
From: Sappy85 <rob...@gm...> - 2014-12-05 01:47:22
|
I have trouble with matplotlib / pyplot / basemap. I plot contour lines (air pressure) on a map. I use clabel to show the value of the contour lines. But the problem: the padding between the value and the contour line is too much. I have found the parameter "inline_spacing", which i have set to zero. But there is still to much free space. Any ideas? <http://matplotlib.1069221.n5.nabble.com/file/n44554/mslp.png> My code is as follows: Thanks a lot. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: Jody K. <jk...@uv...> - 2014-12-05 02:03:03
|
Hi Your code wans't included, but try setting your x and y limits *before* the call to clabel. I think that the problem is that clabel makes a space in the contours according to how large your font is, but if you then resize the plot (zoom in) then the blank space is too large for the labels. Cheers, Jody > On Dec 4, 2014, at 17:47 PM, Sappy85 <rob...@gm...> wrote: > > I have trouble with matplotlib / pyplot / basemap. I plot contour lines (air > pressure) on a map. I use clabel to show the value of the contour lines. But > the problem: the padding between the value and the contour line is too much. > I have found the parameter "inline_spacing", which i have set to zero. But > there is still to much free space. Any ideas? > > <http://matplotlib.1069221.n5.nabble.com/file/n44554/mslp.png> > > My code is as follows: > > > > > Thanks a lot. > > > > -- > View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Sappy85 <rob...@gm...> - 2014-12-05 09:07:34
|
Hi Jody, what exactly du you mean - the plot windows size? I tried this: fig = plt.figure(figsize=(8.4,5.76)) But still the same problem. Regards -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554p44557.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: Jody K. <jk...@uv...> - 2014-12-05 14:45:18
|
I meant plt.xlim and plt.ylim. But its hard to tell what the problem is w/o some sample code. Cheers, Jody > On Dec 5, 2014, at 1:07 AM, Sappy85 <rob...@gm...> wrote: > > Hi Jody, > > what exactly du you mean - the plot windows size? > > I tried this: > fig = plt.figure(figsize=(8.4,5.76)) > > But still the same problem. > > Regards > > > > -- > View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554p44557.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Sappy85 <rob...@gm...> - 2014-12-05 16:42:34
|
Hi Jody,
i have posted the code. Here again:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import pygrib
filename = "file.grib2"
grbs = pygrib.open('/data/' + filename)
grb = grbs[2]
data = grb.values
datac = data*0.01
lats, lons = grb.latlons()
fig = plt.figure()
m = Basemap(projection='stere',lon_0=5,lat_0=90.0,\
llcrnrlon=-25.0,urcrnrlon=60.0,llcrnrlat=30.0,urcrnrlat=60.0,resolution='l')
x, y = m(lons, lats)
levs = range(940,1065,5)
S1=plt.contour(x,y,datac,levs,linewidths=0.5,colors='b')
plt.clabel(S1,inline=1,inline_spacing=0,fontsize=8,fmt='%1.0f',colors='b')
m.drawmapboundary(fill_color='w')
m.drawcoastlines(linewidth=0.2)
plt.savefig('test.png', bbox_inches='tight',pad_inches=0.05, dpi=100)
Regards,
Sappy85
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554p44561.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
|
|
From: Sappy85 <rob...@gm...> - 2014-12-10 00:35:38
|
Hi @all, the problem seems to be solved. Thanks Jody! What i have done: 1.) check out the xlim and ylim after clabel call *xmin, xmax = plt.xlim() # return the current xlim ymin, ymax = plt.ylim() # return the current ylim print xmin,xmax print ymin,ymax* 2.) use and set these limits before clabel call: *plt.xlim(0.0,6475051.47849) plt.ylim(0.0,4412688.31468)* Yes, that's it. Very confusing! I do not understand why that only goes so awkward? Thanks so much! Sappy85 -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554p44582.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: Jody K. <jk...@uv...> - 2014-12-10 01:16:25
|
Not sure, as I don't use basemap too often, but I bet calling: m.drawmapboundary(fill_color='w') before clabel would do the trick Cheers, Jody > On Dec 9, 2014, at 16:35 PM, Sappy85 <rob...@gm...> wrote: > > Hi @all, > the problem seems to be solved. Thanks Jody! > What i have done: > > 1.) check out the xlim and ylim after clabel call > *xmin, xmax = plt.xlim() # return the current xlim > ymin, ymax = plt.ylim() # return the current ylim > print xmin,xmax > print ymin,ymax* > > 2.) use and set these limits before clabel call: > *plt.xlim(0.0,6475051.47849) > plt.ylim(0.0,4412688.31468)* > > Yes, that's it. Very confusing! I do not understand why that only goes so > awkward? > > Thanks so much! > Sappy85 > > > > > > > -- > View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554p44582.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Sappy85 <rob...@gm...> - 2014-12-10 19:32:48
|
Jody, perfect - that work's fine. Regards, Sappy85 -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554p44591.html Sent from the matplotlib - users mailing list archive at Nabble.com. |