Python小工具(3)----- 学术论文快速作图(不同期刊格式图表)

Python数据分析:图表美观清晰,自带对比功能


本文转自Github 点此进入传送门

来自于哈佛天文研究所博士后自己制作的小工具,主要是在matplotlib上增加的一些小功能,支持调用不同期刊要求的格式进行作图

图示及翻译部分引用 量子位公众号推送文章

安装

pip就行(在Matplotlib基础上)

# for latest commit
pip install git+https://github.com/garrettj403/SciencePlots.git

# for lastest release
pip install SciencePlots

The pip installation will automatically move all of the *.mplstyle files into the appropriate directory. If you like, you can also do this manually. First, clone the repository and then copy all of the *.mplstyle files into your Matplotlib style directory. If you’re not sure where this is, in an interactive python console type:

# 手动安装 获得具体路径
import matplotlib
print(matplotlib.get_configdir())

编译器会返回Matplotlib的路径,你可能还需要手动建立一个stylelib文件夹。

使用

science.mplstyle 是这个补充包最基本的一种风格,基本满足一般科研论文的绘图要求,代码如下:

import matplotlib.pyplot as plt
 
plt.style.use('science')
plt.style.use(['science','ieee'])  

#the ieee style will override some of the parameters from the science style in order to configure the plot for IEEE papers (column width, fontsizes, etc.).
with plt.style.context(['science', 'ieee']):
    plt.figure()
    plt.plot(x, y)
    plt.show()

示例

science 风格
在这里插入图片描述
science+grid(网格)风格:
在这里插入图片描述
ieee风格:IEEE期刊对图表的尺寸、文字大小都有要求,同时还要求在黑白印刷时也能清晰呈现,下图是符合要求的science+ieee风格:
在这里插入图片描述
science+scatter(离散)风格:
在这里插入图片描述
Jupyter环境下的notebook风格:
在这里插入图片描述
补充包中的风格也可以和Matplotlib中的已有风格一起调用,例如dark_background + science + high-vis:

在这里插入图片描述
此外,扩展包还提供多种绘图==色彩搭配方案==
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
补充包默认使用Latex字体渲染,如果电脑中没有Latex,可以改用无Latex渲染模式:

plt.style.use(['science','no-latex'])

检查更新版本

pip install SciencePlots
SQL Server 中,`EXISTS` 是一个用于检查是否存在符合特定条件的记录的逻辑运算符。`EXISTS` 返回一个布尔值,即 `TRUE` 或 `FALSE`,表示查询结果集是否包含匹配条件的记录。下面是 `EXISTS` 的详细用法: 1. 基本语法: ```sql SELECT column_name(s) FROM table_name WHERE EXISTS (SELECT column_name FROM table_name WHERE condition); ``` 2. 示例: 假设有两个表,分别为 `customers` 和 `orders`, `customers` 表中包含了所有客户的信息,而 `orders` 表中包含了所有的订单信息。我们需要查询所有已经下过订单的客户的姓名和地址,可以使用以下 SQL 语句: ```sql SELECT customerName, address FROM customers WHERE EXISTS (SELECT * FROM orders WHERE orders.customerID = customers.customerID); ``` 在上面的 SQL 语句中,`EXISTS` 子查询中的条件是查找 `orders` 表中的所有记录,其中 `orders.customerID = customers.customerID` 表示连接两个表的条件,即匹配两个表中的 `customerID` 列。如果 `EXISTS` 子查询返回 `TRUE`,则 `customerName` 和 `address` 列的值会被返回。 3. 注意事项: - `EXISTS` 子查询必须包含一个 `SELECT` 语句,该语句必须返回一个结果集。 - `EXISTS` 子查询中的条件必须使用外部查询中的列或表。 - `EXISTS` 子查询中的 `SELECT` 语句可以是任何有效的 T-SQL 查询语句,包括 `SELECT *`。 - `EXISTS` 子查询中的条件可以包含任何有效的 T-SQL 表达式和运算符。 - `EXISTS` 的性能比使用 `JOIN` 进行连接查询要高,特别是在查询大型数据集时。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值