-
Notifications
You must be signed in to change notification settings - Fork 55
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
Added 20*log10(mag) for Pyqtgraph #395
Merged
marcosfrenkel
merged 20 commits into
toolsforexperiments:master
from
jeremiahnlin:log_scale
Jun 14, 2023
Merged
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fc27f24
Added Log(mag**2)
jeremiahnlin a1c566a
Merge branch 'log_scale' of https://github.com/jeremiahnlin/plottr in…
jeremiahnlin 3767bb0
changed label of logmag
jeremiahnlin af3a0cf
added log lines to new complexRepresentation
jeremiahnlin 0091ebb
made so the complexRepresentation did not have log scale for phase, m…
jeremiahnlin e50f25c
changed complexRepresentation to 20*log10(mag) and took out logarithm…
jeremiahnlin 738a4fd
Merge branch 'toolsforexperiments:master' into log_scale
jeremiahnlin f4c81e7
made style revisions
jeremiahnlin 6a7c1b0
more style edits
jeremiahnlin 98a7b31
Merge branch 'toolsforexperiments:master' into log_scale
jeremiahnlin d28f399
disabled logmag for two independent axes
jeremiahnlin e8ce42b
changed so non-imaginary data will only have the option for real comp…
jeremiahnlin d523cee
Merge branch 'toolsforexperiments:master' into log_scale
jeremiahnlin f8260f0
stylistic changes
jeremiahnlin 875fc75
mypy check fix maybe?
jeremiahnlin 9fa3772
maybe fixed the mypy issues
jeremiahnlin d4ad24b
style changes and fixed crashing error
jeremiahnlin a5638bc
fixed minor naming issue
jeremiahnlin 41dad4d
helped readability with _1dPlot function
jeremiahnlin d5c1ed2
changed readability of _1dPlot
jeremiahnlin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,13 +179,21 @@ def formatSubPlot(self, subPlotId: int) -> None: | |
|
||
def plot(self, plotItem: PlotItem) -> None: | ||
"""Plot the given item.""" | ||
|
||
if plotItem.plotDataType is PlotDataType.unknown: | ||
if len(plotItem.data) == 2: | ||
plotItem.plotDataType = PlotDataType.scatter1d | ||
elif len(plotItem.data) == 3: | ||
plotItem.plotDataType = PlotDataType.scatter2d | ||
|
||
if plotItem.plotDataType in [PlotDataType.scatter1d, PlotDataType.line1d]: | ||
|
||
#If the Complex Representation is for 20*log10(Mag) and it's regarding the Magnitude Plot, not the Phase Plot | ||
if self.complexRepresentation == ComplexRepresentation.log10_MagAndPhase and plotItem.subPlot == 0: | ||
|
||
#Switch the 1d plots to the logarithmic variation | ||
if plotItem.plotDataType == PlotDataType.scatter1d: plotItem.plotDataType = PlotDataType.log10_scatter1d | ||
if plotItem.plotDataType == PlotDataType.line1d: plotItem.plotDataType = PlotDataType.log10_line1d | ||
|
||
if plotItem.plotDataType in [PlotDataType.scatter1d, PlotDataType.line1d,PlotDataType.log10_line1d,PlotDataType.log10_scatter1d]: | ||
self._1dPlot(plotItem) | ||
elif plotItem.plotDataType == PlotDataType.grid2d: | ||
self._colorPlot(plotItem) | ||
|
@@ -212,11 +220,22 @@ def _1dPlot(self, plotItem: PlotItem) -> None: | |
return subPlot.plot.plot(x.flatten(), y.flatten(), name=name, | ||
pen=mkPen(color, width=1), symbol=symbol, symbolBrush=color, | ||
symbolPen=None, symbolSize=symbolSize) | ||
else: | ||
elif plotItem.plotDataType == PlotDataType.log10_line1d: | ||
name = plotItem.labels[-1] if isinstance(plotItem.labels, list) else '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This syntax is cool, but it makes it harder to read compared to a normal if else block |
||
return subPlot.plot.plot(x.flatten(), 20*np.log10(y.flatten()), name=name, | ||
pen=mkPen(color, width=1), symbol=symbol, symbolBrush=color, | ||
symbolPen=None, symbolSize=symbolSize) | ||
elif plotItem.plotDataType == PlotDataType.scatter1d: | ||
name = plotItem.labels[-1] if isinstance(plotItem.labels, list) else '' | ||
return subPlot.plot.plot(x.flatten(), y.flatten(), name=name, | ||
pen=None, symbol=symbol, symbolBrush=color, | ||
symbolPen=None, symbolSize=symbolSize) | ||
#instance of PlotDataType.log10_scatter1d | ||
else: | ||
name = plotItem.labels[-1] if isinstance(plotItem.labels, list) else '' | ||
return subPlot.plot.plot(x.flatten(), 20*np.log10(y.flatten()), name=name, | ||
pen=None, symbol=symbol, symbolBrush=color, | ||
symbolPen=None, symbolSize=symbolSize) | ||
|
||
def _colorPlot(self, plotItem: PlotItem) -> None: | ||
subPlot = self.subPlotFromId(plotItem.subPlot) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just rename it to logMag/Phase or something like that. Like this seems to long for me