Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Visualizing Point Estimates | Section
Statistical Visualization with Seaborn
セクション 1.  14
single

single

bookVisualizing Point Estimates

メニューを表示するにはスワイプしてください

A pointplot represents an estimate of the central tendency (mean) by the position of scatter plot points and provides an indication of uncertainty using error bars.

Pointplot vs. Barplot

Technically, they show the exact same data. However, a pointplot connects the estimates with a line. This visualizes the slope of change, making it easier to see how a variable evolves from one category to another.

Key Parameters

To make the plot easier to read (especially in black-and-white), you can customize the markers and lines for different groups:

  • markers: a list of symbols to use for points (e.g., ['o', 'x']);
  • linestyles: a list of line styles (e.g., ['-'] for solid, ['--'] for dashed);
  • dodge=True: slightly shifts the points along the axis so they don't overlap, making error bars distinct.

Example

Here is a pointplot showing how the average bill changes throughout the week. Notice how the dashed line helps distinguish "Lunch" from "Dinner" even without color.

123456789101112131415161718
import seaborn as sns import matplotlib.pyplot as plt # Load dataset df = sns.load_dataset('tips') # Create a styled pointplot sns.pointplot( data=df, x='day', y='total_bill', hue='time', markers=['o', '^'], # Circle and Triangle markers linestyles=['-', '--'], # Solid and Dashed lines dodge=True # Avoid overlap ) plt.show()
copy
タスク

スワイプしてコーディングを開始

Visualize the tips given on different days to see if there is a trend.

  1. Set the style to 'ticks'. Customize the background color by passing {'axes.facecolor': 'azure'} as the second argument.
  2. Create a pointplot and assign it to variable g:
    • Map 'day' to x and 'tip' to y.
    • Group by 'sex' using hue.
    • Use 'v' (triangle_down) and 'o' (circle) as markers to distinguish genders.
    • Use the 'rocket' palette.
    • Enable dodge=True to separate the error bars.
    • Set capsize to 0.2 to add caps to the error bars.
    • Use solid ('-') and dashed ('--') lines for linestyles.
  3. Set the title to 'Tips pointplot' using the g variable.
  4. Display the plot.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  14
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt