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

Add docs for NonUniformImage #2614

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

j9ac9k
Copy link
Member

@j9ac9k j9ac9k commented Feb 13, 2023

Recently realized that NonUniformImage didn't have an entry in our documentation. This PR aims to correct that, and also makes some minor changes to NonUniformImage as well.

@j9ac9k j9ac9k force-pushed the add-non-uniform-image-to-docs branch 5 times, most recently from 9928f64 to ea25303 Compare February 13, 2023 14:20
@j9ac9k j9ac9k force-pushed the add-non-uniform-image-to-docs branch 2 times, most recently from 9ba3a64 to 1595d8f Compare July 1, 2023 03:49
@j9ac9k j9ac9k force-pushed the add-non-uniform-image-to-docs branch from 1595d8f to 06e1d02 Compare July 8, 2023 17:09
@@ -1,9 +1,14 @@
import math

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'math' is not used.
import numpy as np
import numpy.typing as npt

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'npt' is not used.
@pijyoi
Copy link
Contributor

pijyoi commented Jul 9, 2023

Adapted example from
https://matplotlib.org/stable/gallery/images_contours_and_fields/image_nonuniform.html
to show that provided coords are not the drawn polygon centers

import pyqtgraph as pg
from pyqtgraph.graphicsItems.NonUniformImage import NonUniformImage

import numpy as np

pg.mkQApp()

pw = pg.PlotWidget()
pw.show()

# Linear x array for cell centers:
x = np.linspace(-4, 4, 9)
# Highly nonlinear x array:
x2 = x**3
y = np.linspace(-4, 4, 9)
z = np.sqrt(x[np.newaxis, :]**2 + y[:, np.newaxis]**2)

nuimg = NonUniformImage(x2, y, z)
nuimg.setColorMap(pg.colormap.get("Purples", source="matplotlib"))
pw.addItem(nuimg)

X, Y = np.meshgrid(x2, y, indexing='ij')
pdi = pg.PlotDataItem(X.ravel(), Y.ravel(), pen=None, symbol='x')
pw.addItem(pdi)

pg.exec()

The correct interpretation is that the provided coords are supposed to be the sampled data points, while the drawn polygons are shaded to the nearest coord's Z value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants