Standalone `stipple` plot fails with `AttributeError`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- data-visualization
Research direction
The crash is at plotvars.mymap.scatter( in cfplot/stipple.py (around line 169), where mymap is still None because no gopen/con has created the map. Compare how con and gopen initialise plotvars to see what a standalone stipple call is missing. Reproduce with the snippet in the issue, then check the integration tests for stipple layered on contours. Done means either standalone stipple draws on a projected map, or the maintainers decide it should raise a clear error and document that.
Written by the indexing model from the issue text.
Description
Stipple plots are tested to work, at least as per our integration test examples, when used as an extra layer to a contour plot initiated before the stippling call. However, it appears that the stipple call doesn't work standalone i.e. when called without having a previous con call or similar to set up the plotting figure/canvas variables (some expected object clearly required by the stipple logic), leading to the error shown below.
It is not entirely clear whether the stipple call was ever meant to work standalone - perhaps it was always the intention (though not clarified in the docs) it would be an extra 'layer' to another initiated plot, given there are no standalone stipple examples documented - but regardless I think there is use case to support the standalone call.
Subject of the issue
Stipple plotting via a call to cfp.stipple().
Steps to reproduce
Use the 'Example 17: Basic stipple plot' docs example code, noting that works as-is, but remove the cfp.con(g) line (and the mapset on colour scale which isn't relevant), like so:
f = cf.read(f"cfplot_data/tas_A1.nc")[0]
g = f.subspace(time=15)
cfp.gopen()
cfp.cscale("magma")
# cfp.con(g) # with this commented out but note with it back in the whole plot works
cfp.stipple(f=g, min=220, max=260, size=100, color="#00ff00")
cfp.stipple(
f=g, min=300, max=330, size=50, color="#0000ff", marker="s"
)
cfp.gclose()
Your environment
Using the cfplot-test-env as per https://github.com/NCAS-CMS/cf-plot/blob/main/cfplot-test-env.yml with a local pip install -e . on the main branch of cf-plot.
Expected behaviour
The stipple plot should work to show the stippling in the specified location over the projected map background, regardless of any other plot e.g. contour or vector also added as another layer. Equivalently, stipple should work outside the gopen and gclose wrapper mechanism.
Actual behaviour
Error is:
>>> f = cf.read(f"docs/source/example-datasets/tas_A1.nc")[0]
>>> g = f.subspace(time=15)
>>> cfp.stipple(f=g, min=220, max=260, size=100, color="#00ff00")
Traceback (most recent call last):
File "<python-input-6>", line 1, in <module>
cfp.stipple(f=g, min=220, max=260, size=100, color="#00ff00")
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/slb93/git-repos/cf-plot/cfplot/stipple.py", line 169, in stipple
plotvars.mymap.scatter(
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'scatter'
Relevant data
n/a
- Dominant language
- Python
- Stars
- 21
- Forks
- 11
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NCAS-CMS/cf-plot
-
Add badges to READMEOpendocs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
dependencies infrastructure installation testing
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
-
`title` not showing for `con` with certain projectionsPossibly taken @sadielbartholomew claimed this 1 day ago. Openbug plotting
-
docs enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
All issues in NCAS-CMS/cf-plot
Similar issues
-
Server mode OAuth2: 'NoneType' object is not subscriptable on every request after re-submitting the OAuth2 login while already logged inPossibly taken @Rarasinhoo claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
pgadmin-org/pgadmin4#10733 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
aws-samples/sample-per-model-bedrock#752 ·
Maintainers usually reply within 1 day
-
lesson-submission pending-review
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Ikalus1988/MisakaNet#4452 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OCHA-DAP/topo-tools#250 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day