首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏好奇心Log

    python可视化 | contour、contourf、cartopy补充

    包括画指定的等值线(如588)、如何在一个子图里绘制多个contourf、cartopy的刊误。 一、如何画指定的等值线 以前也有人问过,不知道怎么给忘了,昨天又有个同学来问,于是就解决了。 二、同一张子图中使用两个contourf,尽量少冲突或无冲突 这个问题的出现那就是非常非常久远了,估摸着得有七八个月了。出现的原因是水的相态不同,需要给降雪赋予灰色色系,需要给降雨附上降水色系。 这是不使用挖改时两个contourf的遮盖。 (X, Y, z,levels=levels,cmap='Spectral_r') ac2=ax.contourf(X, Y, z2,levels=levels,cmap='Blues_r') ? 针对两个contourf的混合绘制,如果有更好的办法可以后台留言。

    6.5K20发布于 2021-03-25
  • 来自专栏计算机视觉理论及其实现

    matplotlib:plt.contourf(画等高线)

    np.linspace(-3,3,n)y=np.linspace(-3,3,n)X,Y=np.meshgrid(x,y) #把X,Y传入网格中,X.shape=nn,Y.shape=nnuse plt.contourf to filling contours#X,Y and value for (X,Y) pointplt.contourf(X,Y,height(X,Y),8,alpha=0.75,cmap=plt.cm.hot

    2.8K20编辑于 2022-09-03
  • 来自专栏图像处理与模式识别研究所

    演示在轮廓中使用日志颜色比例和用阴影图案填充等高线图。

    ma.masked_where(z <= 0, z) # Automatic selection of levels works; setting the # log locator tells contourf to use a log scale: fig, ax = plt.subplots() cs = ax.contourf(X, Y, z, locator=ticker.LogLocator(), ())-1), # np.ceil(np.log10(z.max())+1)) # levs = np.power(10, lev_exp) # cs = ax.contourf dimensional, so flatten them. x, y = x.flatten(), y.flatten() fig1, ax1 = plt.subplots() cs = ax1.contourf to use a log scale: fig, ax = plt.subplots() cs = ax.contourf(X, Y, z, locator=ticker.LogLocator(),

    70720编辑于 2022-05-28
  • 来自专栏自学气象人

    【ProPlot库(二)】 动手画你的第一个气象图

    如果要画等值线,则可使用 ds.T[0,-1].plot.contourf(),或者使用 proplot 的 PlotAxes.contourf。 (ax=ax,levels=10,globe=True) #xarray 自带 ax.format(title='xarray contourf plot') ax=axes[1] m=ax.contourf (ds.T[0,-1],globe=True,cmap='viridis',levels=10) ax.colorbar(m) ax.format(title='proplot contourf plot #contour相关参数的网址: https://proplot.readthedocs.io/en/latest/api/proplot.axes.PlotAxes.contourf.html? highlight=contourf#proplot.axes.PlotAxes.contourf #Axes.colorbar相关参数的网址 https://proplot.readthedocs.io

    1.8K31编辑于 2022-10-09
  • 来自专栏气象杂货铺

    Basemap系列教程:自定义colormap

    map.urcrnrx, data.shape[1]) y = linspace(0, map.urcrnry, data.shape[0]) xx, yy = meshgrid(x, y) map.contourf map.urcrnrx, data.shape[1]) y = linspace(0, map.urcrnry, data.shape[0]) xx, yy = meshgrid(x, y) map.contourf 3) 使用 LinearSegmentedColormap.from_list 静态方法创建 colormap 4) 函数返回 levles 和 colormap contourf 传递返回的 levles 给 contourf 函数的 levels 参数。由于部分颜色超出了数据范围,因此有些颜色并没有使用。 ? 没有传递返回的 levels 给 contourf 函数的 levels 参数。contourf 将根据数据进行划分。

    1.4K40发布于 2020-04-20
  • 来自专栏数据 学术 商业 新闻

    Python空间绘图-Colorbar详解

    常用的scatter、contourf是非常适合使用的。第一节我们来简要谈谈常用的colorbar参数,以后例子都基于contourf命令。 cf=ax.contourf(x,y,z,extend='both') fig.colorbar(cf,extend='both') ? 类似于ax.set_yticks( ). cf=ax.contourf(x,y,z) fig.colorbar(cf,ticks=[0,2,4,16]) ? 第十个为label,简单的给色条一个标签: cf=ax.contourf(x,y,z) fig.colorbar(cf,label='色条') ? 关于指数标签,一般来说,在contourf中使用了指数标签命令后,色条会自动变成指数模式。

    22K98发布于 2021-02-22
  • 来自专栏明天依旧可好的专栏

    机器学习第6天:数据可视化神器--Matplotlib

    [-3,3],共256个点 y=np.linspace(-3,3,n) 第3步:将等差数列绑定为网格的形式 X,Y=np.meshgrid(x,y) 第4步:等高划分并填色 #等高划分并着色 plt.contourf 起点为3,终点为3,n为步长,如果n=1,则返回array([ -3., -2., -1., 0., 1., 2., 3.]) 4. contourf() plt.contourf (X,Y,f(X,Y),8,alpha=0.75,cmap=plt.cm.hot) contourf(contour等高线+filling);8 表示等高线分为多少部分,0->2部分,1->3部分,8-

    79210发布于 2019-01-22
  • 来自专栏计算机魔术师

    【深度学习 | 数据可视化】 视觉展示分类边界: Perceptron模型可视化iris数据集的决策边界

    plt.contourf() plt.contourf()用于绘制等高线填充图。它可以根据数据的值来为不同区域着色,并在图表上显示出这些颜色区域之间的边界。 让我们详细解释一下plt.contourf()函数的具体用法: plt.contourf(X, Y, Z) X:表示 x 坐标点的二维数组或网格矩阵。 通过传递以上参数给plt.contourf()函数,我们可以生成一个由等高线填充区域组成的图表。其中每个填充区域都代表了相应坐标点处属性数值所在范围内部分。 通过使用plt.contourf()函数,您可以以视觉方式展示二维数据的分布情况,并更好地理解和呈现数据。 总结 总体而言,整个可视化原理也比较清晰明了。 通过plt.contourf对网格点的每一个预测结果作为其属性画不同颜色等高线实现决策边界的绘制。

    80140编辑于 2023-10-18
  • 来自专栏气python风雨

    GPM卫星数据hdf5格式读取与绘图

    fig = plt.figure(figsize=(20, 12)) ax = fig.add_subplot(1,1,1, projection=ccrs.PlateCarree()) im = ax.contourf UserWarning: The following kwargs were not used by contour: 'cmaps' result = matplotlib.axes.Axes.contourf fig = plt.figure(figsize=(20, 12)) ax = fig.add_subplot(1,1,1, projection=ccrs.PlateCarree()) contourf ax.yaxis.set_minor_locator(plt.MultipleLocator(2)) ax.set_extent(extents) plt.colorbar(contourf ax.yaxis.set_minor_locator(plt.MultipleLocator(2)) ax.set_extent(extents) plt.colorbar(contourf

    1.1K10编辑于 2024-06-20
  • 来自专栏好奇心Log

    Python在线DEM地形图库harmonica

    ax.coastlines(lw=0.4) ax.set_global() ax.stock_img() levs = np.arange(-9000,9000,2000) pc=data.topography.plot.contourf grd" df = xr.open_dataset(filename, decode_cf=False) print(df) lat=df.lat lon=df.lon z=df.z df.z.plot.contourf (region,crs=proj) ax.coastlines(lw=0.4) ax.set_global() ax.stock_img() levs = np.arange(-5,5,1) mfc_contourf =ax.contourf(lon,lat,z,levels=levs,cmap='gist_rainbow',extend='both') cbar=plt.colorbar(mfc_contourf, =[20, 10]) ax = fig.add_subplot(1, 1, 1, projection=ccrs.Orthographic(central_longitude=90)) z.plot.contourf

    1.6K20发布于 2021-10-26
  • 来自专栏气象杂货铺

    Basemap系列教程之基本函数

    contourf from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt from osgeo import gdal 数组 data.shape[1] 及 data.shape[0] 拥有相同的大小 meshgrid 是numpy 中的函数,用两个数组创建一个矩阵,这是绘图所需要的,其中 x 以列重复,y 以行重复 contourf 数据与 contourf 个例中的数据相同 使用 range 函数设置等级。采用高度设置,即从400 m 到 1400 m,每隔100 m 设置一个等值线 colormap 并没有使用默认的 jet。 可以通过传递 cmap 参数给 cubehelix colormap 设置 通常使用 contour 方法时需要设置label,但 contourf 方法不需要设置 1) inline 控制是否移除 数据使用的是 contourf 例子中的数据 colormap 使用的是 contour 例子中的colormap 注意: pcolor 和 pcolormesh 非常相似。

    3.2K10发布于 2020-04-20
  • 来自专栏好奇心Log

    Python可视化 | 三维地图可视化实例

    接下来,我们简单介绍一下如何在3d图中使用contourf函数绘制平面图。 由于3d图的投影结构完全与当前我们的世界相符合,都是三维空间,所以3d图中的contourf与真实世界等值线相同都是立体的,这与我们平时见到的二维等值线图不一致。 利用在前面提到的zdir和offset命令,我们就可以修改三维图的等值线图变为二维等值线图,zdir通俗理解就是将传入的维度降维,offset表示降维后的等值线填色图放置的层次: ax.contourf ax.contourf(X,Y,Z,zdir='z',offset=0) ax.contourf(X,Y,Z,zdir='z',offset=30) ax.contourf(X,Y,Z,zdir='z' ax.contourf(X,Y,Z,zdir='z',offset=0) ax.contourf(X,Y,Z,zdir='y',offset=70) ax.contourf(X,Y,Z,zdir='x'

    5.1K21发布于 2021-05-08
  • 来自专栏气python风雨

    meteva站点插值填色与白化

    , 60] axs = meb.creat_axs(2, map_extend,ncol=2,sup_fontsize=7) cmap = cmaps.radar_1 image = meb.add_contourf ,add_colorbar=False) #image = meb.add_scatter_text(axs[0], sta, tag=0, font_size=5) image = meb.add_contourf map_extend = [110, 125, 35, 45] axs = meb.creat_axs(2, map_extend,ncol=2,sup_fontsize=7) image = meb.add_contourf ,"tianjin","hebei"]) #image = meb.add_scatter_text(axs[0], sta, tag=0, font_size=5) image = meb.add_contourf projection=ccrs.PlateCarree()) ax1.set_extent([110, 125, 35, 45]) cmap1 = cmaps.radar # 绘制填色分布图 im1 = ax1.contourf

    59010编辑于 2024-06-20
  • 来自专栏数据 学术 商业 新闻

    Iris!真的!几乎所有常见的地图它都能绘制...

    iris.sample_data_path("toa_brightness_stereographic.nc") cube = iris.load_cube(file_path) qplt.contourf fname = iris.sample_data_path("air_temp.pp") temperature = iris.load_cube(fname) # Plot #1: contourf with axes longitude from -180 to 180 plt.figure(figsize=(12, 5)) plt.subplot(121) qplt.contourf (temperature, 15) plt.gca().coastlines() # Plot #2: contourf with axes longitude from 0 to 360 proj = ccrs.PlateCarree(central_longitude=-180.0) plt.subplot(122, projection=proj) qplt.contourf

    43501编辑于 2024-05-25
  • 来自专栏caoqi95的记录日志

    matplotlib 绘制轮廓图和 3D 图

    轮廓图 matplotlib.pyplot.contourf(args, data=None, **kwargs) Call signature: contour([X, Y,] Z, [levels] = np.arange(0, 21) Y = np.arange(0, 21) X, Y = np.meshgrid(X, Y) levels = range(-5, 6, 1) CS = plt.contourf Contourf Demo [2]. mplot3d tutorial

    1.4K50发布于 2019-06-11
  • 来自专栏自学气象人

    气象绘图——复杂的三维图

    上述两种栅格化,具体有什么用,目前视觉效果最好的就是这一种: 在三维图中实现contourf可视化 我们之前曾经推送过如何进行contourf的三维可视化,但是有一定的问题,小值区的色块总是会被遮盖, 随后使用contourf的投影参数: kw={'vmin':rh.min(), 'vmax':rh.max(), 'levels':np.arange(0,110,10)} cross_lon _90=ax.contourf( rh[:,:,0].values, Y[:,:,0], Z[:,:,0],cmap='Blues', zdir='x 对于contourf函数来说,使用levels参数,就可以控制数据的上下界限,例如: kw={'levels':np.arange(70,105,5)} cross_lon_90=ax.contourf contourf命令如法炮制便可。

    1.9K11编辑于 2023-06-21
  • 来自专栏自学气象人

    气象绘图——白化杂谈

    这几种白化方法中,最知名的应该是maskout这个方法,而与后面三种不同的是,这个方法是真正的裁剪,因为按照其使用流程: ac=ax.contourf(...) clip=maskout.shp2clip 其他四种都是先判别是不是在指定shp文件内部,然后再画,但是geopandas.clip的办法与Masterpiece的办法会改变数据的维度,导致无法还原为2D数组,不能用在contourf绘制等值线图上 (x,y,z) ac2=ax2.contourf(x,y,z) for i in ac1.collections: i.set_clip_path(boundary,transform=ax1. 这个数据裁剪不改变数组的维度,所以后期可以用在contourf上。 这种方法可以保住数据的维度为2D结构,所以既可以用scatter也可以用contourf绘图。不过在网格比较粗的情况下会出现裁剪劣化,不该白化的地方掉白变多。

    2.1K33编辑于 2023-06-21
  • 来自专栏自学气象人

    气象绘图cmap、cbar超详细版(附示例)

    常见的绘图命令scatter、contour、contourf、pcolormesh等都可以引入cmap与colorbar,下面四幅图分别使用了前述四种绘图命令绘制,并更改了每一幅图使用的颜色映射表: colormap=mpl.cm.get_cmap(' Reds ' ) ax.contourf ax1.contourf(X,Y,Z,cmap='Reds') ax2.contourf(X,Y,Z,cmap 5. shrink(axes特性,colorbar的收缩比例) 该参数控制colorbar的收缩比例,在收缩时,colorbar长宽都会变化,如: CS=ax1.contourf(X,Y,Z,cmap= Matplotlib的开发者并没有将设定等级的levels命令进行普遍化,造成该便捷命令只能在contour、contourf里使用。

    25.9K238编辑于 2022-11-02
  • 来自专栏好奇心Log

    Python可视化 | 温度、水深&CTRL向量空间分布图

    False,True],linewidth=0.5,color='red',dashes=[1,4],size=14) lonproj,latproj = proj(llon, llat) c1=ax.contourf False,True],linewidth=0.5,color='red',dashes=[1,4],size=14) lonproj, latproj = proj(llon, llat) c1=ax.contourf interest (where to draw the contours) isobars = [0,200,500,1000,1500,2000,2500,3000,3500,4000,5000] c1=ax.contourf False,True],linewidth=0.5,color='red',dashes=[1,4],size=14) lonproj, latproj = proj(llon, llat) c1=plt.contourf interest (where to draw the contours) isobars = [0,200,500,1000,1500,2000,2500,3000,3500,4000,5000] c1=plt.contourf

    2.2K30发布于 2021-03-25
  • 来自专栏气python风雨

    如何绘制wrfout文件的垂直速度变量

    figure fig = plt.figure(figsize=(20,12)) ax = plt.axes() # Make the contour plot wspd_contours = ax.contourf wspd_contours = ax.contourf(to_np(wspd_cross), cmap=get_cmap("jet")) 台风利奇马WA剖面 In [13]: import numpy figure fig = plt.figure(figsize=(20,12)) ax = plt.axes() # Make the contour plot wa_contours = ax.contourf wa_contours = ax.contourf(to_np(wa_cross), cmap=get_cmap("jet")) 台风利奇马OMEGA剖面 In [14]: import numpy as omega_contours = ax.contourf(to_np(omega_cross), cmap=get_cmap("jet")) 小结 1.

    1.5K10编辑于 2024-06-20
领券