matplotlib安装 ubuntu
时间: 2023-08-18 18:08:26 浏览: 99
要在Ubuntu上安装matplotlib,你可以按照以下步骤进行操作:
1. 使用以下命令安装所需的依赖库:
sudo apt-get install libpng-dev libfreetype6-dev pkg-config
2. 使用以下命令安装matplotlib:
pip install -i http://pypi.douban.com/simple matplotlib
3. 如果你使用Python 2.7,请执行以下步骤:
3.1 使用以下命令安装six库:
cd /usr/local/lib/python2.7/dist-packages
wget http://pypi.doubanio.com/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz#md5=d12789f9baf7e9fb2524c0c64f1773f8
tar -zxvf six-1.11.0.tar.gz
cd six-1.11.0
sudo python setup.py install
3.2 使用以下命令安装prettyplotlib:
pip install -i http://pypi.douban.com/simple prettyplotlib
4. 如果你使用Python 3.x,可以跳过以上步骤。
5. 最后,你可以使用以下代码测试matplotlib是否成功安装并显示一个正弦函数:
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
show()
希望这些步骤对你有帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Ubuntu 安装 matplotlib](https://blog.csdn.net/weixin_33794672/article/details/86259957)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [ubuntu下安装matplotlib](https://blog.csdn.net/menyangyang/article/details/44281151)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文