0

I would like to use a colormap to plot a ridge plot with the library joypy but it seams not to work. I need your help to fix then problem: Here is the script:

import matplotlib as mpl
from matplotlib import pyplot as plt
import matplotlib.colors
from matplotlib import cm
from matplotlib.colors import to_rgb, LinearSegmentedColormap
import matplotlib.ticker as ticker
from matplotlib import mlab
import numpy as np
import pandas as pd
import joypy

df_titles = ['Force 0nm','Force 25nm', 'Force 50nm','Force 70nm','Force 90nm','Force 110nm']


barcolor0light = matplotlib.colors.to_rgb('#FFBFBF')
barcolor25light = matplotlib.colors.to_rgb('#FFEABF')
barcolor50light = matplotlib.colors.to_rgb('#BFFFBF')
barcolor70light = matplotlib.colors.to_rgb('#BFBFFF')
barcolor90light = matplotlib.colors.to_rgb('#DCBFF9')
barcolor110light = matplotlib.colors.to_rgb('#FFBFF2') 
colorslight =[barcolor0light,barcolor25light,barcolor50light,barcolor70light,barcolor90light,barcolor110light]
lightCmap =matplotlib.colors.ListedColormap(colorslight)
grouped = df2s.groupby("Hue", sort=False)
fig, axes = joypy.joyplot(grouped, column = "Force", labels=df_titles, hist = True,
                         overlap=10, bins = 50, fade=True,grid=True,alpha=0.75,
                           linewidth=1, colormap=lightCmap)
for ax in axes:
    ax.set_xlim(0,2500)
    ax.set_ylim(0,32)
    ax.xaxis.set_major_locator(ticker.MultipleLocator(250))
    ax.xaxis.set_minor_locator(ticker.MultipleLocator(50))

About the df2s data, here is a screenshot of the panda dataframe that I am using. There are 2 column: "Force" and "Hue" (I am using "Hue" to separate 6 populations in the column "Force"):

Dataframe:

enter image description here

I have created a colormap called lightCmap based on a list of 6 colors (see above) and i want to use it to plot the histogram with only one color per row but on the joy plot I have only one color for each row as you can see Joyplot:

enter image description here

and i do not see where is my mistake .... (I know that the colormap is working on other plot)

Could you help me .... thanks

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
phigirard
  • 1
  • 2

0 Answers0