当前位置: 主页 > 彩票资讯 >

Python用matplotlib 画3d图怎么才能看到绘制过程?

发布时间:2020-02-13 | 来源:未知 | 作者:admin | 点击: 次 | 3d画
matplotlib怎么在pycharm中绘制出来图

近看《Python数据析》本书自写代码直用Pycharm练习候碰plot()绘图能显示问题网翻找知乎篇答试像行且答住提供from pylab import *太符合编程规范Stackoverflow找想要答案特析给家:
问题代码能绘图功:

import pandas as pd
from numpy import *
import matplotlib.pyplot as plt
ts = pd.Series(random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()

解决案:导入matplotlib.pyplot库绘图再调用matplotlib.pyplot.show()能绘制图显示
(注:面发现知乎篇问答评论区提供):

import pandas as pd
from numpy import *
import matplotlib.pyplot as plt
ts = pd.Series(random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
plt.show()

关于【Python用matplotlib 画3d图怎么才能看到绘制过程?】其他看法

matplotlib的pyplot子库提供了和matlab类似的绘图API,方便用户快速绘制2D图表。例子:
# coding=gbk
'''
Created on Jul 12, 2014
python 科学计算学习:numpy快速处理数据测试@author: 皮皮
'''
import string
import matplotlib.pyplot as plt
import numpy as np
if __name__ == '__main__':
file = open(E:machine_learningdatasetshousing_datahousing_data_ages.txt, 'r')linesList = file.readlines()
# print(linesList)
linesList = [line.strip().split(,) for line in linesList]
file.close()
print(linesList:)
print(linesList)
# years = [string.atof(x[0]) for x in linesList]
years = [x[0] for x in linesList]
print(years)
price = [x[1] for x in linesList]
print(price)
plt.plot(years, price, 'b*')#,label=$cos(x^2)$)plt.plot(years, price, 'r')
plt.xlabel(years(+2000))
plt.ylabel(housing average price(*2000 yuan))plt.ylim(0, 15)
plt.title('line_regression & gradient decrease')plt.legend()
plt.show()

吉彩网彩票预测专家(整理搜集)

Powered by http://www.jitajianpu.com © 2004-2009 DesDev Inc.
Copyright © 2002-2020 吉彩网彩票预测专家 版权所有