import numpy as np
import matplotlib.pyplot as plt

# x轴刻度标签
x_ticks = ['a''b''c''d''e''f']
# x轴范围(0, 1, ..., len(x_ticks)-1)
x = np.arange(len(x_ticks))
# 第1条折线数据
y1 = [532416]
# 第2条折线数据
y2 = [316524]

# 设置画布大小
plt.figure(figsize=(106))
# 画第1条折线,参数看名字就懂,还可以自定义数据点样式等等。
plt.plot(x, y1, color='#FF0000', label='label1', linewidth=3.0)
# 画第2条折线
plt.plot(x, y2, color='#00FF00', label='label2', linewidth=3.0)

# 给第1条折线数据点加上数值,前两个参数是坐标,第三个是数值,ha和va分别是水平和垂直位置(数据点相对数值)。
for a, b in zip(x, y1):
    plt.text(a, b, '%d'%b, ha='center', va= 'bottom', fontsize=18)
# 给第2条折线数据点加上数值
for a, b in zip(x, y2):
    plt.text(a, b, '%d'%b, ha='center', va= 'bottom', fontsize=18)

# 画水平横线,参数分别表示在y=3,x=0~len(x)-1处画直线。
plt.hlines(30, len(x)-1, colors = "#000000", linestyles = "dashed")

# 添加x轴和y轴刻度标签
plt.xticks([r for r in x], x_ticks, fontsize=18, rotation=20)
plt.yticks(fontsize=18)

# 添加x轴和y轴标签
plt.xlabel(u'x_label', fontsize=18)
plt.ylabel(u'y_label', fontsize=18)

# 标题
plt.title(u'Title', fontsize=18)

# 图例
plt.legend(fontsize=18)

# 保存图片
plt.savefig('./figure.pdf', bbox_inches='tight')
# 显示图片
plt.show()
import numpy as np
import matplotlib.pyplot as plt

# x轴刻度标签
x_ticks = ['a''b''c''d''e''f']
# 柱的宽度
barWidth = 0.25
# 第1个柱的x轴范围(每个柱子的中点)(0, 1, ..., len(x_ticks)-1)
x1 = np.arange(len(x_ticks))
# 第2个柱的x轴范围(每个柱子的中点)
x2 = [x + barWidth for x in x1]
# 第1个柱数据
y1 = [532416]
# 第2个柱数据
y2 = [316524]

# 设置画布大小
plt.figure(figsize=(106))
# 画第1个柱
plt.bar(x1, y1, color='#FF0000', width=barWidth, label='label1')
# 画第2个柱
plt.bar(x2, y2, color='#00FF00', width=barWidth, label='label2')

# 给第1个柱数据点加上数值,前两个参数是坐标,第三个是数值,ha和va分别是水平和垂直位置(数据点相对数值)。
for a, b in zip(x1, y1):
    plt.text(a, b, '%d'%b, ha='center', va= 'bottom', fontsize=18)
# 给第2个柱数据点加上数值
for a, b in zip(x2, y2):
    plt.text(a, b, '%d'%b, ha='center', va= 'bottom', fontsize=18)

# 画水平横线
plt.hlines(30, len(x_ticks)-1+barWidth, colors = "#000000", linestyles = "dashed")

# 添加x轴和y轴刻度标签
plt.xticks([r + barWidth/2 for r in x1], x_ticks, fontsize=18)
plt.yticks(fontsize=18)

# 添加x轴和y轴标签
plt.xlabel(u'x_label', fontsize=18)
plt.ylabel(u'y_label', fontsize=18)

# 标题
plt.title(u'Title', fontsize=18)

# 图例
plt.legend(fontsize=18)

# 保存图片
plt.savefig('./figure.pdf', bbox_inches='tight')
# 显示图片
plt.show()
import numpy as np
import matplotlib.pyplot as plt

# 设置画布大小
plt.figure(figsize=(1010))
# 设置每块区域的标签
labels = ['a''b''c''d''e']
# 设置每块区域离圆心的距离,这里a区域凸出一点点
explode = [0.050.010.010.010.01]
# 设置每块区域的值
values = [15243]
# 设置每块区域的颜色
colors = ['#F5DEB3''#87CEFA''#FFB6C1''#90EE90''#D3D3D3']

_, l_text, p_text = plt.pie(values, explode=explode, labels=labels, autopct='%1.1f%%', colors=colors)

# 设置标签字体大小
for t in l_text:
    t.set_size(18)
# 设置数值字体大小
for t in p_text:
    t.set_size(18)

# 标题
plt.title(u'Title', fontsize=18)

# 图例
plt.legend(fontsize=18)

# 保存图片
plt.savefig('./figure.pdf', bbox_inches='tight')
# 显示图片
plt.show()
Reference
[1]

如何在论文中画出漂亮的插图?: https://www.zhihu.com/question/21664179


java 周第一天 获取某天 java中获取下周一时间

我需要使用日历来执行此方法,基本上我得到了星期几(1、2、3),每个int代表星期几(星期一,星期二)不是按此顺序,但是逻辑是这样。我需要获取星期几的日期,假设今天是星期一,而用户选择Wednsesday,我需要获取下星期三的日期。我目前的逻辑是:calendar.set(Calendar.DAY_OF_WEEK, dayOfWeek); calendar.set(Calendar.HOUR_OF

java 层级遍历二叉树 按层遍历二叉树java

LeetCode题:107. 二叉树的层次遍历II给定一个二叉树,返回其节点值自底向上的层次遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历)例如:给定二叉树 [3,9,20,null,null,15,7],3/ \9 20/ \15 7返回其自底向上的层次遍历为:[ [15,7], [9,20], 迭代实现: * Definition for a binary

4.shell命令概述 Shell作用:命令解释器 介于操作系统内核与用户之间,负责解释命令行 获得命令帮助 内部命令help 命令的“--help” 选项 使用man命令阅读手册页 命令行编辑的几个辅助 5.Redis启动器项目RunRedisServer开源了