Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow kwarg passing to plotting functions. #379

Open
GB123185 opened this issue Apr 7, 2020 · 4 comments
Open

Allow kwarg passing to plotting functions. #379

GB123185 opened this issue Apr 7, 2020 · 4 comments

Comments

@GB123185
Copy link

GB123185 commented Apr 7, 2020

What do you need help with?

This is probably not an eqcorrscan-specific issue, but rather an issue with my lack of experience with matplotlib. I return a matplotlib figure object, which is attached, and I'm trying to modify the matplotlib figure to change the color and x/y labels. I get the current axes, and modify the axes, but when I try to show the figure again, the figure, 'outfig' does not update. I'm probably missing one small thing in the code, but I just can't pinpoint what it is! The code and outfig is provided below. Thank you for your help!

EDIT: Sorry, I just have to save the figure - re-plotting outfig.show() doesn't automatically update the figure. Apologies for the stupid issue being raised!

Provide an example so that we can reproduce your problem

import glob
template_names = glob.glob('templates/template*.ms')             

from eqcorrscan.utils.plotting import cumulative_detections                   
outfig = cumulative_detections(
    detections=detections, template_names=template_names, 
    plot_grouped=True, plot_legend=True, title='Detections 16-01-18 to 22-02-18', 
    save=False, rate=True, return_figure=True)                                    
ax = outfig.gca()                                                             
ax.set_xlabel('Dates from January 16 2018')                                   
outfig.show() 

Figure_1

@calum-chamberlain
Copy link
Member

All good - you can set the show argument to False to stop the initial plotting, then you can make updates and show later. e.g.:

import glob
template_names = glob.glob('templates/template*.ms')             

from eqcorrscan.utils.plotting import cumulative_detections                   
outfig = cumulative_detections(
    detections=detections, template_names=template_names, 
    plot_grouped=True, plot_legend=True, title='Detections 16-01-18 to 22-02-18', 
    save=False, rate=True, return_figure=True, show=False)                               
ax = outfig.gca()                                                             
ax.set_xlabel('Dates from January 16 2018')                                   
outfig.show() 

should work for you. I have never known how to update a plot after you have shown it.

@GB123185
Copy link
Author

GB123185 commented Apr 7, 2020

Ok Great. Thanks Calum. On a related note, the histogram color is fixed to darkgrey in the source code. Do you happen to know about a quick and easy way to edit the color of the histogram bins from darkgrey, to say, red? Cheers.

@calum-chamberlain
Copy link
Member

Ugh, so it is - that needs to be changed. I'm afraid I don't know how you can do that after the fact. I will leave this open to remind me to pass kwargs through to the plots for cumulative-plotting.

@GB123185
Copy link
Author

GB123185 commented Apr 7, 2020

Ok cool. Yeah it's not a big deal, I really appreciate your help and responsiveness. Cheers,
Greg

@calum-chamberlain calum-chamberlain added this to the 0.5.0 milestone Aug 14, 2020
@calum-chamberlain calum-chamberlain changed the title [HELP] Modifying Cumulative Detection Matplotlib Figure Allow kwarg passing to plotting functions. Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants