python - Multiple linestyles with seaborn.facetgrid -


i have data in tidy ('long form') pandas.dataframe looking (shortened) :

    dataset  limit type_long type  distance  count  frequency 0       pos     -1      dr-3   dr        -3     17   0.005866 1       pos     -1      dr-2   dr        -2     70   0.024155 2       pos     -1      dr-1   dr        -1    124   0.04278 ...     ...     ...     ...    ...       ...   ...    ... 810     neg    -10       dr9   dr         9    435   0.033565 811     neg    -10      dr10   dr        10    432   0.033333 812     neg    -10      ir-3   ir        -3    260   0.02006 

i managed represent data intended:

1 subplot per 'type' x , y being 'distance' , 'frequency' respectively , separating 'pos' , 'neg' datasets using continuous , dashed lines. code here:

grid = sns.facetgrid(df, col = 'type', hue= 'limit', legend_out = true)  grid.map(sns.pointplot, 'distance', 'frequency', 'dataset', linestyles = ['-', ':'], markers=['','']).set_titles('{col_name}') grid.add_legend() plt.show() 

which gives ugly output: 'pos' dataset appears transparent , legend disapeared (i cannot post image, sorry)

i don't understand strange behaviour of pointplot in case. there way correct transparency? or maybe better approach create figure.

for legend guess conflict between 2 hue definitions. there way display double legend colors limits , linestyle dataset ?

i've made minimal working example seaborn datasets, graphs awfull shows problem well:

import seaborn sns  titanic = sns.load_dataset('titanic') sns.set(style="ticks") grid = sns.facetgrid(titanic, col = 'class', hue= 'embark_town', legend_out = true)  grid.map(sns.pointplot, 'fare', 'age', 'sex', linestyles = ['-', ':'], markers=['','']) grid.add_legend()  


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -