Altair
import altair as alt import pandas as pd # 1. Data data = pd.DataFrame({'a': ['A', 'B', 'C'], 'b': [28, 55, 43]}) # 2. & 3. Chart + Mark + Encoding chart = alt.Chart(data).mark_bar().encode( x='a', y='b' ) # Display (if in notebook) # chart.show() Use code with caution. Copied to clipboard 3. Data Transformation & Aggregation
Create a specific (e.g., click a bar to filter data)? altair
Map data columns to visual properties (e.g., .encode(x='column1', y='column2') ). Example: Simple Bar Chart import altair as alt import pandas as pd # 1
You can refine your plot by adding titles, changing colors, and adjusting axes using .properties() and alt.Axis() . Chart + Mark + Encoding chart = alt
alt.Chart(data).mark_bar().encode( x=alt.X('a', title='Category'), y=alt.Y('b', title='Value'), color='a' # Color by category ).properties( title='My First Altair Chart', width=400, height=300 ) Use code with caution. Copied to clipboard 5. Interaction
Choose the chart type (e.g., mark_point() , mark_bar() , mark_line() ).
Learn how to (e.g., lines and points)?
