python:pyecharts绘制自动化地图

import pandas as pd 
from pyecharts import options as opts
from pyecharts.charts import Map, Geo
from pyecharts.globals import ChartType
geo = Geo()
geo.add_schema(
    maptype="china",label_opts=opts.LabelOpts(is_show=True),
    itemstyle_opts=opts.ItemStyleOpts(color="#a4a4a4", 
                                      border_color="#005454"))
coordinate = pd.read_excel("G:/地图/11月/11月15日/单位经纬度.xlsx")
for j in range(0,len(coordinate['单位名称'])):
    geo.add_coordinate(
        name=coordinate['单位名称'][j],
        longitude=float(coordinate['longitude'][j]),
        latitude=float(coordinate['latitude'][j])
     )

list1 = list()
for i in range(0,len(coordinate['单位名称'])):
    a = coordinate['单位名称'][i]
    b = int(coordinate['状态'][i])
    c = [a,b]
    list1.append(c)
    
geo.add(
     "科研单位/高校分布",list1,
     type_=ChartType.EFFECT_SCATTER,
        )
geo.set_series_opts(label_opts=opts.LabelOpts(is_show=True, formatter="{b}", font_size=10))
geo.set_global_opts(visualmap_opts=opts.VisualMapOpts(
    is_piecewise=True,  # 表示分段
    pieces=[{'min': 0 , 'max':1, 'label':"待争取单位", 'color':'skyblue'},
            {'min': 1 , 'max':2, 'label':"11月前合作单位", 'color':'#37a2da'},
            {'min': 1 , 'max':3, 'label':"新增合作单位", 'color':'red','font_size':20}
            ],
    #pos_left="800", pos_top="250"
    ))
geo.render('G:/地图/11月/11月15日/11月15日地图2.html')

在这里插入图片描述

# 1 -----------------------------------------------------------------------
library(readxl)
library(ggplot2)
danwei <- read_excel('g:/地图/11月/11月15日/订单数量(单位).xlsx')
p1 <- ggplot2::ggplot(danwei,aes(Var1,Freq,fill='#1c9cd8'))+
  geom_bar(stat = 'identity',position = "stack",
           show.legend = F,col='black',
           width = 0.8)+coord_flip()+
  labs(title = '2022年3-11月\n科研单位/高校订单数量',x = '',y = '')+
  geom_text(aes(label=lab,col='black'),size=5,#position = position_dodge(0,10),
            vjust=0.5,hjust=-0,col='black')+
  scale_y_continuous(limits=c(0,30))+
  theme(text = element_text(face = 'bold'))
p1
# -------------------------------------------------------------------------
yuefen <- read_excel('g:/地图/11月/11月15日/订单数量(月份).xlsx')
yuefen$yuefen <- factor(yuefen$yuefen,levels = yuefen$yuefen)
p2 <- ggplot2::ggplot(yuefen,aes(yuefen,Freq,fill='#1c9cd8'))+
  geom_bar(stat = 'identity',position = "stack",
           show.legend = F,col='black',
           width = 0.8)+coord_flip()+
  labs(title = '2022年3-11月\n每月订单数量',x = '',y = '')+
  geom_text(aes(label=lab,col='black'),size=5,
            vjust=0.5,hjust=-0.5,col='black')+
  scale_y_continuous(limits=c(0,18))+
  theme(text = element_text(face = 'bold'))
p2
library(patchwork)
pdf("g:/地图/11月/11月15日/订单-月份-单位.pdf",
    family="GB1",width = 12,height =7)

p1+p2
dev.off()

https://wwl.lanzoue.com/b01k446of
密码:hxaj

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值