[PYTHON] Comparison of 4 styles that can be passed to seaborn with set_context

What is this article?

Python has a visualization library called seaborn based on matplotlib. matplotlib is a little tricky when trying to draw a beautiful graph, but seaborn is recommended because it can draw a beautiful graph quickly.

seaborn has a function called set_context that sets the font size of the graph. By selecting one of the four styles of paper, notebook, talk, and poster for set_context and passing it as an argument, you can change the font size of the graph according to the publication medium.

This article is a memo when comparing the output when each of paper, notebook, talk, poster is passed to set_context.

Output in 4 styles

paper paper.png

notebook notebook.png

talk talk.png

poster poster.png

Comparison of 4 styles

Regarding the font size, it increases in the order of paper <notebook <talk <poster.

Paper has very small letters. Although it is called paper, I think that even if you put it in a journal, the characters will be crushed and you will not be able to read it.

It's hard to tell what kind of situation talk is supposed to be, but I think it's probably supposed to be on a slide. However, the graph to be placed on the slide is difficult to read unless the font size is increased, so it may be better to select poster when placing it on the slide.

Source code

import seaborn as sns
import matplotlib.pyplot as plt


def draw(context):
    sns.set_context(context)
    plt.clf()
    plt.plot([0, 1], [0, 1])
    plt.legend(["line"])
    plt.xlabel("this is x label")
    plt.ylabel("this is y label")
    plt.title(context)
    plt.tight_layout()
    plt.savefig(context + ".png ")

if __name__ == '__main__':
    context_lst = ["paper", "notebook", "talk", "poster"]
    [draw(context) for context in context_lst]

reference

seaborn.set_context

Recommended Posts

Comparison of 4 styles that can be passed to seaborn with set_context
[Python] Introduction to web scraping | Summary of methods that can be used with webdriver
Format summary of formats that can be serialized with gensim
File types that can be used with Go
List packages that can be updated with pip
A memo for making a figure that can be posted to a journal with matplotlib
List of tools that can be used to easily try sentiment analysis of Japanese sentences in Python (try with google colab)
Convert images from FlyCapture SDK to a form that can be used with openCV
Color list that can be set with tkinter (memorial)
Python knowledge notes that can be used with AtCoder
How to create a property of relations that can be prefetch_related by specific conditions
Limits that can be analyzed at once with MeCab
How to display hover text and text that can be executed by clicking with Minecraft plugin
[Python] A program to find the number of apples and oranges that can be harvested
Summary of things that need to be installed to run tf-pose-estimation
It seems that Skeleton Tracking can be done with RealSense
Basic knowledge of DNS that can not be heard now
NumPy zeros can be defined even with a size of 0
Processing of python3 that seems to be usable in paiza
I investigated the pretreatment that can be done with PyCaret
Let's make a diagram that can be clicked with IPython
Evaluation index that can be specified in GridSearchCV of sklearn
I tried to expand the database so that it can be used with PES analysis software
[Python] A program that finds the maximum number of toys that can be purchased with your money
Predict the number of cushions that can be received as laughter respondents with Word2Vec + Random Forest
[Python] Make a graph that can be moved around with Plotly
Investigation of DC power supplies that can be controlled by Python
Become familiar with (want to be) around the pipeline of spaCy
Install packages that need to be compiled with Python3 with pip [Windows]
I made a shuffle that can be reset (reverted) with Python
Make a currency chart that can be moved around with Plotly (2)
Make a Spinbox that can be displayed in HEX with Tkinter
Make a currency chart that can be moved around with Plotly (1)
Get a list of camera parameters that can be set with cv2.VideoCapture and make it a dictionary type
requirements.txt can be commented out with #
Confirmation that rkhunter can be installed
Easy padding of data that can be used in natural language processing
Basic summary of scraping with Requests that beginners can absolutely understand [Python]
[Python] A program that calculates the number of socks to be paired
How to make a rock-paper-scissors bot that can be easily moved (commentary)
Create a web app that can be easily visualized with Plotly Dash
Mathematical optimization that can be used for free work with Python + PuLP
Maximum number of function parameters that can be defined in each language
"Manim" that can draw animation of mathematical formulas and graphs with Python
Acoustic signal processing module that can be used with Python-Sounddevice ASIO [Basic]
Address to the bug that node.surface cannot be obtained with python3 + mecab
I wanted to quickly create a mail server that can be used freely with postfix + dovecot on EC2
It seems that cancelall childorders can be used to cancel all parent orders (special orders) with the bitflyer API
Article that can be a human resource who understands and masters the mechanism of API (with Python code)
[Python3] Code that can be used when you want to change the extension of an image at once