Skip to content

Commit

Permalink
add plot type example files for gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindougherty-noaa committed Jul 1, 2024
1 parent bd8d326 commit f14651c
Show file tree
Hide file tree
Showing 27 changed files with 816 additions and 839 deletions.
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
sphinx_gallery_conf = {
'capture_repr': (),
'filename_pattern': '^((?!skip_).)*$',
'examples_dirs': example_dirs,
'gallery_dirs': gallery_dirs, # path to where to save gallery generated output
'examples_dirs': ['../galleries/examples', '../galleries/plot_types'],
'gallery_dirs': ['examples', 'plot_types'], # path to where to save gallery generated output
'backreferences_dir': '../build/backrefs',
'subsection_order': gallery_order_sectionorder,
'within_subsection_order': gallery_order_subsectionorder,
# 'subsection_order': gallery_order_sectionorder,
# 'within_subsection_order': gallery_order_subsectionorder,
'matplotlib_animations': True
}

Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following links provide further documentation on the different branches with

calculations.md
io.md
galleries/plot_types/index
plots.md
statistics.md
utilities.md

3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ EMCPy
:hidden:

getting_started/index
galleries/examples/index
plot_types/index
examples/index
installing


Expand Down
8 changes: 5 additions & 3 deletions galleries/examples/README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Gallery
-------
.. _examples:

Examples
--------

The following examples show off the functionality of EMCPy. The examples
give reference to what can be done with these collection of tools. Please
do not hesitate to issue a pull request to add further examples!
do not hesitate to issue a pull request to add further examples!
810 changes: 0 additions & 810 deletions galleries/examples/Untitled.ipynb

This file was deleted.

18 changes: 2 additions & 16 deletions galleries/plot_types/README.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
## Plots

The plotting section of EMCPy is the most mature and is used as the backend plotting for (eva)[https://github.com/JCSDA-internal/eva]. It uses declarative, object-oriented programming approach to handle complex plotting routines under the hood to simplify the experience for novice users while remaining robust so more experienced users can utilize higher-level applications.

### Design
The design was inspired by Unidata's (MetPy)[https://github.com/Unidata/MetPy] declarative plotting syntax. The structure is broken into three different levels: plot type level, plot level, figure level

#### Plot Type Level
This is the level where users will define their plot type objects and associated plot details. This includes adding the related data the user wants to plot and how the user wants to display the data i.e: color, line style, marker style, labels, etc.

#### Plot Level
This level is where users design how they want the overall subplot to look. Users can add multiple plot type objects and define titles, x and y labels, colorbars, legends, etc.

#### Figure Level
This level where users defines high-level specifics about the actual figure itself. These include figure size, layout, defining information about subplot layouts like rows and columns, saving the figure, etc.
.. _plot-types:

Plot Types
----------

Here is a collection of the current plot types that are currently available using EMCPy.
Here is a collection of the plot types that are currently available using EMCPy.
4 changes: 4 additions & 0 deletions galleries/plot_types/basic/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. _basic:

Basic
=====
53 changes: 53 additions & 0 deletions galleries/plot_types/basic/bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
Bar Plot
--------
Below is an example of how to plot a bar
plot using EMCPy's plotting method.
"""

import numpy as np
import matplotlib.pyplot as plt

from emcpy.plots.plots import BarPlot
from emcpy.plots.create_plots import CreatePlot, CreateFigure


def main():
# Create bar plot

# Grab sample bar plot data
x_pos, heights = _getBarData()

# Create bar plot object
bar = BarPlot(x_pos, heights)
bar.color = 'tab:red'

# Create plot object and add features
plot1 = CreatePlot()
plot1.plot_layers = [bar]
plot1.add_xlabel(xlabel='X Axis Label')
plot1.add_ylabel(ylabel='Y Axis Label')
plot1.add_title("Bar Plot")

# Create figure
fig = CreateFigure()
fig.plot_list = [plot1]
fig.create_figure()

plt.show()


def _getBarData():
# Generate test data for bar graphs

x = ['a', 'b', 'c', 'd', 'e', 'f']
heights = [5, 6, 15, 22, 24, 8]

x_pos = [i for i, _ in enumerate(x)]

return x_pos, heights

if __name__ == '__main__':
main()
54 changes: 54 additions & 0 deletions galleries/plot_types/basic/horizontal_bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""
Horizontal Bar Plot
-------------------
Below is an example of how to plot a horizontal
bar plot using EMCPy's plotting method.
"""

import numpy as np
import matplotlib.pyplot as plt

from emcpy.plots.plots import HorizontalBar
from emcpy.plots.create_plots import CreatePlot, CreateFigure


def main():
# Create horizontal bar plot

# Grab sample bar plot data
y_pos, widths= _getBarData()

# Create horizontal bar plot object
bar = HorizontalBar(y_pos, widths)
bar.color = 'tab:green'

# Create plot object and add features
plot1 = CreatePlot()
plot1.plot_layers = [bar]
plot1.add_xlabel(xlabel='X Axis Label')
plot1.add_ylabel(ylabel='Y Axis Label')
plot1.add_title("Horizontal Bar Plot")

# Create figure
fig = CreateFigure()
fig.plot_list = [plot1]
fig.create_figure()

plt.show()


def _getBarData():
# Generate test data for bar graphs

x = ['a', 'b', 'c', 'd', 'e', 'f']
heights = [5, 6, 15, 22, 24, 8]

x_pos = [i for i, _ in enumerate(x)]

return x_pos, heights


if __name__ == '__main__':
main()
45 changes: 45 additions & 0 deletions galleries/plot_types/basic/horizontal_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
Horizontal Line Plot
--------------------
Below is an example of how to plot a horizontal
line using EMCPy's plotting method.
"""

import numpy as np
import matplotlib.pyplot as plt

from emcpy.plots.plots import HorizontalLine
from emcpy.plots.create_plots import CreatePlot, CreateFigure


def main():

y = 5

# Create vertical line plot object
hlp = HorizontalLine(y)
hlp.label = 'Horizontal Line'

# Add vertical line plot object to list
plt_list = [hlp]

# Create plot object and add features
plot1 = CreatePlot()
plot1.plot_layers = [hlp]
plot1.add_title('Horizontal Line Plot')
plot1.add_xlabel('X Axis Label')
plot1.add_ylabel('Y Axis Label')
plot1.add_legend(loc='upper right')

# Create figure
fig = CreateFigure()
fig.plot_list = [plot1]
fig.create_figure()

plt.show()


if __name__ == '__main__':
main()
8 changes: 4 additions & 4 deletions galleries/plot_types/basic/line.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Creating a simple line plot
---------------------------
Line Plot
---------
Below is an example of how to plot a basic
line plot using EMCPy's plotting method.
Expand Down Expand Up @@ -29,12 +29,12 @@ def main():
# Create plot object and add features
plot1 = CreatePlot()
plot1.plot_layers = [lp]
plot1.add_title('Test Line Plot')
plot1.add_title('Line Plot')
plot1.add_xlabel('X Axis Label')
plot1.add_ylabel('Y Axis Label')
plot1.add_legend(loc='upper right')

# Create figure and save as png
# Create figure
fig = CreateFigure()
fig.plot_list = [plot1]
fig.create_figure()
Expand Down
52 changes: 52 additions & 0 deletions galleries/plot_types/basic/scatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
Scatter Plot
------------
Below is an example of how to plot a basic
scatter plot using EMCPy's plotting method.
"""

import numpy as np
import matplotlib.pyplot as plt

from emcpy.plots.plots import Scatter
from emcpy.plots.create_plots import CreatePlot, CreateFigure


def main():

# Create scatter plot object
x1, y1, x2, y2 = _getScatterData()
sctr1 = Scatter(x1, y1)

# Create plot object and add features
plot1 = CreatePlot()
plot1.plot_layers = [sctr1]
plot1.add_title(label='Scatter Plot')
plot1.add_xlabel(xlabel='X Axis Label')
plot1.add_ylabel(ylabel='Y Axis Label')

# Create figure
fig = CreateFigure()
fig.plot_list = [plot1]
fig.create_figure()

plt.show()

def _getScatterData():
# Generate test data for scatter plots

rng = np.random.RandomState(0)
x1 = rng.randn(100)
y1 = rng.randn(100)

rng = np.random.RandomState(0)
x2 = rng.randn(30)
y2 = rng.randn(30)

return x1, y1, x2, y2


if __name__ == '__main__':
main()
45 changes: 45 additions & 0 deletions galleries/plot_types/basic/vertical_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
Vertical Line Plot
------------------
Below is an example of how to plot a vertical
line using EMCPy's plotting method.
"""

import numpy as np
import matplotlib.pyplot as plt

from emcpy.plots.plots import VerticalLine
from emcpy.plots.create_plots import CreatePlot, CreateFigure


def main():

x = 5

# Create vertical line plot object
vlp = VerticalLine(x)
vlp.label = 'Vertical Line'

# Add vertical line plot object to list
plt_list = [vlp]

# Create plot object and add features
plot1 = CreatePlot()
plot1.plot_layers = [vlp]
plot1.add_title('Vertical Line Plot')
plot1.add_xlabel('X Axis Label')
plot1.add_ylabel('Y Axis Label')
plot1.add_legend(loc='upper right')

# Create figure
fig = CreateFigure()
fig.plot_list = [plot1]
fig.create_figure()

plt.show()


if __name__ == '__main__':
main()
4 changes: 4 additions & 0 deletions galleries/plot_types/gridded/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. _gridded

Gridded
=======
Loading

0 comments on commit f14651c

Please sign in to comment.