matplotlib / matplotlib/mplfinance

Feature Request: to show only specific figure created in `plotting.py` instead of using `plt.show` we use `fig.show`.

Open
#510 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
4.4k
Forks
678
PR merge metrics
No merged PRs in 30d

Description

Running the code below, Python will pop up the window (figure) created in `plotting.py` and also the `userfig` window I created independently in this piece of code. Usually if people want to show the `userfig` they can just run `userfig.show()`.
```
userfig,ax = plt.subplots() #I want the userfig to be only showed when I use userfig.show()

dataset = pd.read_csv('data.csv', index_col=0, parse_dates= True)
n = len(dataset)

mpf.plot(dataset, type='candle', style='yahoo')
```

This is due to in `plotting.py` it uses `plt.show` (which shows all figures created in your Python code, including outside the `plotting.py`) instead of specific figure `fig.show` to show only the figure created in `plotting.py`. The downside of using `fig.show` is that it does not have `block` argument, but i think this is not a problem, since the user can use `plt.show` independently outside the `plotting.py` if he needs the `block`. I propose this change in `plotting.py`:

**BEFORE**:
![Capture2](https://user-images.githubusercontent.com/35247692/158976902-67c9aa2a-adba-4ad0-ac10-68d371b79c5a.PNG)

**AFTER**:
![Capture](https://user-images.githubusercontent.com/35247692/158976897-eac1df4b-cbbe-416b-b1d7-f72300142a5d.PNG)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in plotting.py and reproduce the provided example with a separately created userfig and a candlestick plot from data.csv. Check the display behavior with the current and proposed figure-specific call; done means plotting the dataset does not also display the independently created userfig, while users can still call plt.show() separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.