請不要更多的基本情節

“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.pswp.cn/news/389171.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389171.shtml
英文地址,請注明出處:http://en.pswp.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[]>…

c# 對COM+對象反射調用時地址參數處理 c# 對COM+對象反射調用時地址參數處理

使用反射的方式調用組件里面的方法&#xff0c;經常會遇見一些象地址參數的處理&#xff0c;在C#中表現為ref參數&#xff0c;比如用C#寫了一個裝配件&#xff0c;里面有一個方法openProcedure(string ProcName,int paraCount,ref string[] parameters)&#xff0c;最后有一個r…

android觸摸消息的派發過程

1.觸摸消息是消息獲取模塊直接派發給應用程序的。 2.觸摸消息在處理時&#xff0c; 需要根據觸摸坐標計算該消息應該派發給哪個View/ViewGroup, 在案件取消處理中不存在 該計算過程。 3.沒有類似”系統按鍵”的”系統觸摸鍵”&#xff0c; 應用程序可完全控制觸摸行為。 4.子…

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 …

遞歸原來可以so easy|-連載(3)

本期我們再通過幾個例子&#xff0c;加深遞歸的理解和熟練度。 上期有一個練習題&#xff1a;用遞歸逆序輸出一個包含整型數據的鏈表。 先完成這個練習題。 對于程序員來說&#xff0c;代碼是最好的溝通工具&#xff0c;什么都不說&#xff0c;上代碼&#xff1a; public class…

Viewport3D 類Viewport3D 類Viewport3D 類

.NET Framework 類庫Viewport3D 類更新&#xff1a;2007 年 11 月為三維可視內容提供呈現圖面。命名空間&#xff1a; System.Windows.Controls程序集&#xff1a; PresentationFramework&#xff08;在 PresentationFramework.dll 中&#xff09;用于 XAML 的 XMLNS&#xf…

升級android 6.0系統

How to Fix errors by manually flashing Marshmallow update 鏡像下載for nexus Factory image Step 1: Download the [Marshmallow factory image](http://www.theandroidsoul.com/download-mra58k-android-6-0-marshmallow-update-released-for-nexus-5-nexus-6-nexus-9-n…

AGC 022 B - GCD Sequence

題面在這里&#xff01; 鍛煉腦子的小構造題。。。 一開始被 a[]<30000 且 序列 gcd 1所困擾&#xff0c;但是發現這并沒有什么&#xff0c;因為我接下來發現了一種總是能構造出 序列和是6的倍數的方案。 首先如果 n3 的話輸出樣例&#xff0c;因為只有這種情況沒法用我的方…

最接近原點的 k 個點_第K個最接近原點的位置

最接近原點的 k 個點In this article, I will be explaining to you one of the problems that you may find when tackling questions in data structures and algorithm. You will need some basic knowledge of data structures in order to understand the optimized solut…

網絡瀏覽器如何工作

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…

[轉載]使用.net 2003中的ngen.exe編譯.net程序

ngen.exe程序為.net 2003自帶&#xff0c; 在&#xff1a;/windows/microsoft.net/framework/v1.1.4322目錄下ngen.exe ngen能把.net框架的東西編譯成機器碼.... 網友&#xff1a;Visual Studio .NET 2003程序的運行速度怎么樣&#xff0c;我有一個感覺&#xff0c;V…

基于Redis實現分布式鎖實戰

背景在很多互聯網產品應用中&#xff0c;有些場景需要加鎖處理&#xff0c;比如&#xff1a;秒殺&#xff0c;全局遞增ID&#xff0c;樓層生成等等。大部分的解決方案是基于DB實現的&#xff0c;Redis為單進程單線程模式&#xff0c;采用隊列模式將并發訪問變成串行訪問&#x…