To plot a seaborn line plot with a custom color palette and highlight the current year, you can follow these steps:
main.py54 chars3 lines
Prepare your data in a pandas DataFrame. Let's assume you have a DataFrame named df
with two columns: year
and value
.
Define a custom color palette using seaborn's light_palette()
function:
main.py85 chars2 lines
This will create a palette of lighter blue shades, with the number of colors equal to the number of unique years in your data.
palette
as the color
parameter to the lineplot()
function. Additionally, you can use the hue
parameter to distinguish different years visually:main.py72 chars2 lines
plt.axvline()
function to draw a vertical line at the current year:main.py173 chars5 lines
main.py11 chars2 lines
Here's the complete code:
main.py631 chars21 lines
This code will generate a line plot with a custom color palette where certain years appear lighter and the current year is highlighted.
gistlibby LogSnag