iPython中的Seaborn统计数据可视化中的缺省字体 [英] Default fonts in Seaborn statistical data visualization in iPython

查看:357
本文介绍了iPython中的Seaborn统计数据可视化中的缺省字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图运行 stanford.edu/~mwaskom/software/seaborn/

在他们的一些教程中,我重新创建了以下代码:
$ b

但是让我困扰的是使用的字体不是为Seaborn,但最接近的一个。



有没有人在调整matplotlib中的字体选择方面有经验?如何使用matplotlib的字体管理器的任何好的教程?

解决方案

正如Joe注意到,默认情况下,但它很容易安装。这是我在Ubuntu环境下的Travis上测试的结果:
$ b $ pre $ sudo apt-get install msttcorefonts -qq

Seaborn也暴露了样式控件顶层的字体选项,所以您也可以轻松使用安装在您的系统上。据我所知,你可以通过这种方式获得可能的字体列表:

  import matplotlib as mpl 
font_paths = mpl.font_manager.findSystemFonts()
font_objects = mpl.font_manager.createFontList(font_paths)
font_names = [字体对象中f的f.name]
打印font_names

一旦您找到要使用的一个,只需设置它即可,例如

  sns.set(font =Verdana)

当然,这必须在每个脚本/笔记本的顶部完成(这很烦人),所以改进非默认样式的使用是在0.3。

After multiple problems trying to run stanford.edu/~mwaskom/software/seaborn/ in Anaconda and Enthought for Mac (many problems with dependencies and versions), I was able to run it from an Enthought virtual environment in Ubuntu (running on VirtualBox).

Following some of their tutorials I recreated the following:

But it bothers me that the fonts in use are not the ones designed for Seaborn, but the closest one.

Does anybody has experience in tweaking the font selection in matplotlib? Any good tutorial on how to use matplotlib's font manager?

解决方案

As Joe notes, Arial isn't installed on Ubuntu by default, but it's easy to install. This is what I do for testing on Travis, which is an Ubuntu environment:

sudo apt-get install msttcorefonts -qq

Seaborn also exposes the font option at the top level of the style control, so you could also easily use one that's installed on your system. As far as I can tell from poking around, you can get a list of possible fonts this way:

import matplotlib as mpl
font_paths = mpl.font_manager.findSystemFonts()
font_objects = mpl.font_manager.createFontList(font_paths)
font_names = [f.name for f in font_objects]
print font_names

Once you've found one you want to use, just set it by doing, e.g.,

sns.set(font="Verdana")

Of course this would have to be done at the top of every script/notebook that's going to generate seaborn plots (which is annoying), so improving the use of non-default styles is on the roadmap for 0.3.

这篇关于iPython中的Seaborn统计数据可视化中的缺省字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆