请不要更多的基本情节

“If I see one more basic blue bar plot…”

“如果我再看到一个基本的蓝色条形图……”

After completing the first module in my studies at Flatiron School NYC, I started playing with plot customizations and design using Seaborn and Matplotlib. Much like doodling during class, I started coding other styled plots in our jupyter notebooks.

在纽约Flatiron学校完成学习的第一个模块后,我开始使用Seaborn和Matplotlib进行剧情定制和设计。 就像在上课时涂鸦一样,我开始在我们的Jupyter笔记本中编写其他样式的图。

After reading this article, you’re expected to have at least one quick styled plot code in mind for every notebook.

阅读本文后,您应该为每个笔记本至少记住一个快速样式化的绘图代码。

没有更多的默认情况下,品牌专卖店,基本情节, (No more default, store brand, basic plots, please!)

如果您无能为力,请使用Seaborn。 (If you can do nothing else, use Seaborn.)

You have five seconds to make a decent looking plot or the world will implode; use Seaborn!

您有五秒钟的时间可以绘制出像样的情节,否则世界将会崩溃。 使用Seaborn!

Seaborn, which is build using Matplotlib can be an instant design upgrade. It automatically assigns the labels from your x and y values and a default color scheme that’s less… basic. ( — IMO: it rewards good, clear, well formatted column labeling and through data cleaning) Matplotlib does not do this automatically, but also does not ask for x and y to be defined at all times depending on what you are looking to plot.

使用Matplotlib构建的Seaborn可以立即进行设计升级。 它会根据您的x和y值自动分配标签,并且使用默认的配色方案(基本)。 (— IMO:它会奖励良好,清晰,格式正确的列标签以及通过数据清理)Matplotlib不会自动执行此操作,但是也不会始终根据要绘制的内容要求定义x和y。

Here are the same plots, one using Seaborn and one Matplotlib with no customizations.

这是相同的图,一个使用Seaborn,另一个使用Matplotlib,没有进行自定义。

Image for post
Image for post
Seaborn — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — Matplotlib
Seaborn — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —并将

从顶部样式化 (Style it from the top)

Depending on the data you are visualizing, changing the style and backgrounds may increase interpretability and readability. You can carry this style throughout by implementing a style at the top of your code.

根据所显示的数据,更改样式和背景可能会提高解释性和可读性。 您可以通过在代码顶部实现样式来贯穿整个样式。

There is a whole documentation page on styline via Matplotlib.

通过Matplotlib在样式上有一个完整的文档页面。

# insert a style under your libraries to set the tone for your entire notebook
# Use styles like 'ggplot', 'dark_background', or 'fivethirtyeight'import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inlineplt.style.use('ggplot')# More on color below, but you can also set a color palette at the top
# Or set the plt style using the seaborn styles in matplotlib# sns.set_palette('colorblind')
# plt.style.use('seaborn-colorblind')

Styling can be as simple as setting the style with a simple line of code after your imported libraries. GGPlot changed the background to grey, and has a specific font. There are many more styles you can tryout.

样式设置很简单,就像在导入的库之后用简单的代码行设置样式一样。 GGPlot将背景更改为灰色,并具有特定的字体。 您可以尝试更多样式。

Image for post
Using plot styling, Matplotlib (top) Seaborn (bottom) Notice that Seaborn automatically labeled the plot.
使用绘图样式,Matplotlib(顶部)Seaborn(底部)请注意,Seaborn自动标记了绘图。

XKCD; 厚脸皮的小东西 (XKCD; a cheeky little extra)

# If you want to be cheeky, you can use the xkcd styled plot
# However, you'll want to run plt.rcdefaults() after to clear this style if you don't want them to continue. 
# The XKCD style acts differently than normal styling. 
# plt.xkcd()

Fun. Not professional. But so fun.

好玩 不专业。 但是很好玩。

Image for post

Be aware that if you use this XKCD style it will continue until you reset the defaults by running plt.rcdefaults()…

请注意,如果使用此XKCD样式,它将继续进行,直到通过运行plt.rcdefaults()重置默认值为止。

漂亮的颜色哦! (PRETTY COLORS OMG!)

Image for post
- Seaborn single color names. These can also be used in Matplot Lib. Image from Matplotlib.org
-Seaborn单色名称。 这些也可以在Matplot库中使用。 图片来自Matplotlib.org

Make your plots engaging. Color theory comes into play here. Seaborn has a mix of palettes which can also be used in Matplot lib, plus you can also make your own.

让您的情节吸引人。 颜色理论在这里起作用。 Seaborn有多种调色板,也可以在Matplot lib中使用,此外您还可以自己制作。

Single Colors: One and Done

单色:一种完成

  • Above is a list of single color names you can call to change lines, scatter plots, and more.

    上面是一个单色名称的列表,您可以调用它们来更改线条,散布图等。

Lazy? Seaborn’s Default Themes

懒? Seaborn的默认主题

  • has six variations of default

    有六种默认值
  • deep, muted, pastel, bright, dark, and colorblind

    deepmutedpastelbrightdarkcolorblind

  • use color as an argument after passing in x, y, and data

    传入x,y和数据后,将color用作参数
  • color = ‘colorblind’

    color ='色盲'

Work Smarter Not Harder: Pre-Fab Palettes

更加聪明地工作:预制调色板

color_palette() accepts any seaborn palette or matplotlib colormap

color_palette()接受任何seaborn调色板或matplotlib颜色图

  • Personal favorites are ‘magma’ and ‘viridis’

    个人最爱是“岩浆”和“ viridis”

Control Freak? Custom Palettes / Using Hex Codes

控制怪胎? 自定义调色板/使用十六进制代码

  • pretty_colors = [“#FF4653”, “#EE7879”,“#DDEDF4”, “#2A3166”]

    pretty_colors = [“#FF4653”,“#EE7879”,“#DDEDF4”,“#2A3166”]
  • pass in hex codes which can be found online

    传递可以在网上找到的十六进制代码
  • create a kind and add in specifics, play around with the parameters for more customized palettes

    创建种类并添加详细信息,使用参数创建更多自定义调色板
Image for post
Many ways to choose a color palette.
选择调色板的多种方法。

一切都应该有标签 (Everything Should Have a Label)

Here we are using Matplotlib, but we have added a single color for each line, a title, x and y labels, and a legend for clear concise interpretation.

在这里,我们使用Matplotlib,但为每行添加了一种颜色,标题,x和y标签以及图例,以使内容简洁明了。

Every variable has a home, and it sparks joy now, right? — Think how would Marie Kondo code.

每个变量都有一个家,现在它会激发欢乐,对吗? —想想Marie Kondo的代码。

plt.style.use('seaborn')
fig=plt.figure(figsize = (18,10))python = plt.plot('Python', data = df, color = 'forestgreen')
javascript = plt.plot('JavaScript', data = df, color = 'darkorange')plt.title('Python vs JavaScript Developer Salaries', size = 30)plt.xlabel('Age', size = 25)
plt.xticks(size = 15)plt.ylabel('Salaries', size = 25)
plt.yticks(size = 15)plt.legend(labels = ['Python Developers', 'JavaScript Developers'], prop={"size":16}, loc = 'center right');

Simple, but clear.

简单但清晰。

Image for post

Overall, pretty simple right? Well, now you have no excuses for those ugly basic plots. I hope you found this helpful and mayb a little bit fun. There’s so much more on color and design in the documentation, so once you’ve mastered these quick tips, dive in on the documentation below!

总体来说,很简单吧? 好吧,现在您没有那些难看的基本情节的借口。 我希望您觉得这很有帮助,可能会有点有趣。 文档中包含有关颜色和设计的更多内容,因此,一旦您掌握了这些快速提示,请深入阅读以下文档!

Enjoy? Let’s be friends. Follow me on GitHub, Instagram, and Medium

请享用? 成为朋友吧。 在GitHub , Instagram和Medium上关注我

Today’s Data by Corey Schaffer: Developer Salaries Data

今日数据作者:Corey Schaffer :开发人员薪金数据

Documentation:

说明文件:

Seaborn

Seaborn

Matplotlib

Matplotlib

Other Resources:

其他资源:

XKCD in Matplotlib

Matplotlib中的XKCD

翻译自: https://medium.com/python-in-plain-english/no-more-basic-plots-please-59ecc8ac0508

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/389171.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Powershell-获取DHCP地址租用信息

需求&#xff1a;业务需要获取现阶段DHCP服务器所有地址租用信息。 1.首先查看DHCP相关帮助信息&#xff1a;2.确定执行命令并获取相关帮助信息&#xff1a;help Get-DhcpServerv4Scope 名称 Get-DhcpServerv4Scope 语法 Get-DhcpServerv4Scope [[-ScopeId] <ipaddress[]>…

python 交互式流程图_使用Python创建漂亮的交互式和弦图

python 交互式流程图Python中的数据可视化 (Data Visualization in Python) R vs Python is a constant tussle when it comes to what is the best language, according to data scientists. Though each language has it’s strengths, R, in my opinion has one cutting-edg…

机器学习解决什么问题_机器学习帮助解决水危机

机器学习解决什么问题According to Water.org and Lifewater International, out of 57 million people in Tanzania, 25 million do not have access to safe water. Women and children must travel each day multiple times to gather water when the safety of that water …

Viewport3D 类Viewport3D 类Viewport3D 类

.NET Framework 类库Viewport3D 类更新&#xff1a;2007 年 11 月为三维可视内容提供呈现图面。命名空间&#xff1a; System.Windows.Controls程序集&#xff1a; PresentationFramework&#xff08;在 PresentationFramework.dll 中&#xff09;用于 XAML 的 XMLNS&#xf…

网络浏览器如何工作

Behind the scenes of modern Web Browsers现代Web浏览器的幕后花絮 The Web Browser is inarguably the most common portal for users to access the web. The advancement of the web browsers (through the series of history) has led many traditional “thick clients”…

让自己的头脑极度开放

为什么80%的码农都做不了架构师&#xff1f;>>> 一. 头脑封闭和头脑开放 头脑封闭 你是否经常有这样的经历&#xff0c;在一次会议或者在一次小组讨论时&#xff0c;当你提出一个观点而被别人否定时&#xff0c;你非常急迫地去反驳别人&#xff0c;从而捍卫自己的尊…

简介DOTNET 编译原理 简介DOTNET 编译原理 简介DOTNET 编译原理

简介DOTNET 编译原理 相信大家都使用过 Dotnet &#xff0c;可能还有不少高手。不过我还要讲讲Dotnet的基础知识&#xff0c;Dotnet的编译原理。 Dotnet是一种建立在虚拟机上执行的语言&#xff0c;它直接生成 MSIL 的中间语言&#xff0c;再由DotNet编译器 JIT 解释映象为本机…

RecyclerView详细了解

关于RecyclerView大家都不陌生了&#xff0c;它的使用也越来越受欢迎&#xff0c;现在总体了解一下RecyclerView的作用&#xff0c;为什么会有RecyclerView呢&#xff0c;我用ListView也能干所有的事情啊&#xff0c;尺有所短&#xff0c;寸有所长&#xff0c;先来看看Recycler…

案例与案例之间的非常规排版

In 1929 the Cond Nast publishing group brought Russian-born Mehemed Fehmy Agha—who had been working for the German edition of Vogue magazine—to America as art director for House & Garden, Vanity Fair, and the senior edition of Vogue.1929年&#xff0c…

熊猫分发_熊猫新手:第二部分

熊猫分发This article is a continuation of a previous article which kick-started the journey to learning Python for data analysis. You can check out the previous article here: Pandas for Newbies: An Introduction Part I.本文是上一篇文章的延续&#xff0c;该文…

浅析微信支付:申请退款、退款回调接口、查询退款

本文是【浅析微信支付】系列文章的第八篇&#xff0c;主要讲解商户如何处理微信申请退款、退款回调、查询退款接口&#xff0c;其中有一些坑的地方&#xff0c;会着重强调。 浅析微信支付系列已经更新七篇了哟&#xff5e;&#xff0c;没有看过的朋友们可以看一下哦。 浅析微信…

view工作原理-计算视图大小的过程(onMeasure)

view的视图有两种情况&#xff1a; 内容型视图&#xff1a;由视图的内容决定其大小。图形型视图&#xff1a;父视图为view动态调整大小。 ### measure的本质 把视图布局使用的“相对值”转化成具体值的过程&#xff0c;即把WRAP_CONTENT,MATCH_PARENT转化为具体的值。 measur…

基于Redis实现分布式锁实战

背景在很多互联网产品应用中&#xff0c;有些场景需要加锁处理&#xff0c;比如&#xff1a;秒杀&#xff0c;全局递增ID&#xff0c;楼层生成等等。大部分的解决方案是基于DB实现的&#xff0c;Redis为单进程单线程模式&#xff0c;采用队列模式将并发访问变成串行访问&#x…

数据分析 绩效_如何在绩效改善中使用数据分析

数据分析 绩效Imagine you need to do a bank transaction, but the website is so slow. The page takes so much time to load, all you can see is a blue circle.想象您需要进行银行交易&#xff0c;但是网站是如此缓慢。 该页面需要花费很多时间来加载&#xff0c;您只能看…

隐私策略_隐私图标

隐私策略During its 2020 Worldwide Developers Conference, Apple spent time on one of today’s hottest topics — privacy. During the past couple of years, Apple has been rolling out various public campaigns aiming to position itself as a company that respect…

您一直在寻找5+个简单的一线工具来提升Python可视化效果

Insightful and aesthetic visualizations don’t have to be a pain to create. This article will prevent 5 simple one-liners you can add to your code to increase its style and informational value.富有洞察力和美学的可视化不必费心创建。 本文将防止您添加到代码中…

figma 安装插件_彩色滤光片Figma插件,用于色盲

figma 安装插件So as a UX Designer, it is important to design with disabilities in mind. One of these is color blindness. It is important to make sure important information on your product is legible to everyone. This is why I like using this tool:因此&…

产品观念:更好的捕鼠器_故事很重要:为什么您需要成为更好的讲故事的人

产品观念&#xff1a;更好的捕鼠器重点 (Top highlight)Telling a compelling story helps you get your point across effectively else you get lost in translation.讲一个引人入胜的故事可以帮助您有效地传达观点&#xff0c;否则您会迷失在翻译中。 Great stories happen…

7月15号day7总结

今天复习了springMVC的框架搭建。 思维导图&#xff1a; 转载于:https://www.cnblogs.com/kangy123/p/9315919.html

设计师的10种范式转变

For $250, a business can pay a graphic designer to create a logo for their business. Or, for $10,000 a business can hire a graphic designer to form a design strategy that contextually places the business’s branding in a stronghold against the market it’s…