Skip to content
Snippets Groups Projects
Commit 8ecc7676 authored by Martin Bauer's avatar Martin Bauer
Browse files

2D scenarios - drops on interface - falling drop

parent 6627dffa
No related merge requests found
......@@ -44,6 +44,30 @@ def scalarField(field, **kwargs):
return res
def scalarFieldAlphaValue(field, color, clip=False, **kwargs):
import numpy as np
import matplotlib
field = np.swapaxes(field, 0, 1)
color = matplotlib.colors.to_rgba(color)
fieldToPlot = np.empty(field.shape + (4,))
for i in range(3):
fieldToPlot[:, :, i] = color[i]
if clip:
normalizedField = field.copy()
normalizedField[normalizedField<0] = 0
normalizedField[normalizedField>1] = 1
else:
min, max = np.min(field), np.max(field)
normalizedField = (field - min) / (max - min)
fieldToPlot[:, :, 3] = normalizedField
res = imshow(fieldToPlot, origin='lower', **kwargs)
axis('equal')
return res
def scalarFieldContour(field, **kwargs):
field = np.swapaxes(field, 0, 1)
res = contour(field, **kwargs)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment