I use tidyverse everyday, knowing about siuba and plotnine is really mind-blowing for me! Python is totally new for me, but the way you explain the translation from R makes it easier for me grasp python. Love it! Can't wait for the second part about modelling. Cheers!
@ronit80673 жыл бұрын
ggplot(aes(annual_salary)) + geom_histogram() + scale_x_log10(labels = dollar_format()) + labs(x = "Annual") its a distribution plot, with correct bin settings it looks the same but i am unable to set the x-ticks in python. i am trying to recreate this plot using plotnine, but i cannot find any solution. any ideas are appreciated.
@ChowTheDog3 жыл бұрын
Are you having trouble with finding a python version of dollar_format or is something else happening? (E.g. the x ticks show up at funky breakpoints etc)
@ronit80673 жыл бұрын
@@ChowTheDog exactly the dollar format thing, plus the grid that form on the plot is significantly different. technically the distribution that is generated is the same.
@ChowTheDog3 жыл бұрын
I often use something like this to do percentages, so maybe something similar will work? (The labels argument takes a function that runs on each break value) percent_format = lambda l: ["{:.0f}%".format(v * 100) for v in l] scale_x_log10(labels=percent_format) I'm guessing you'll have to specify break values where you want them. plotnine's author is pretty good with issues on GitHub, so maybe something is up there about this..
@ChowTheDog3 жыл бұрын
Wait sorry, I guess it takes a function that operates over an array (or something), since format_percent is using a comprehension
@ronit80673 жыл бұрын
@@ChowTheDog yeah thats what i assumed and tried using the “breaks” argument, but it doesn’t change the graph at all. I thought that the dollar format was an internal ggplot method. as i did not see any such function in the script.