matplotlib命令与格式:tick_params参数刻度线样式设置

matplotlib命令与格式:tick_params参数刻度线样式设置
原文:https://blog.csdn.net/helunqu2017/article/details/78736554

import csv
import matplotlib.pyplot as plt
from datetime import datetime

file_path = r'E:\workplace\python\code\csvcsv\death_valley_2014.csv'
highs, lows, dates = [], [], []

with open(file_path, encoding='UTF-8') as f_csv:
    reader = csv.reader(f_csv)
    header = next(f_csv)

    for row in reader:
        try:
            high = int(row[1])
            low = int(row[3])
            current_date = datetime.strptime(row[0], "%Y-%m-%d")
        except ValueError:
            print(str(current_date)+ " : missing")
        finally:
            highs.append(high)
            lows.append(low)
            dates.append(current_date)

plt.plot(dates, highs, color='r', alpha=0.5)
plt.plot(dates, lows, color='b', alpha=0.5)
plt.fill_between(dates, highs, lows, facecolor='b', alpha=0.1)

# tick_params参数
# 参数axis 选择坐标轴,both/x/y
# 参数which的值为 'major'、'minor'、'both',分别代表设置主刻度线、副刻度线以及同时设置,默认值为'major'
# 参数direction的值为'in'、'out'、'inout',分别代表刻度线显示在绘图区内侧、外侧以及同时显示
# 参数labelsize用于设置刻度线标签的字体大小
# 参数bottom, top, left, right的值为布尔值,分别代表设置绘图区四个边框线上的的刻度线是否显示
# 参数labelbottom, labeltop, labelleft, labelright的值为布尔值,分别代表设置绘图区四个边框线上的刻度线标签是否显示
plt.tick_params(which='major', labelsize=16, colors="red", direction='in')
plt.show()

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值