Hello everyone,
I am using the Fenics-Dolfin 2019.1.0 and trying to scale the color-bar of a plot, based on a region zoomed region in the plot. I have zoomed into that region using matplotlib.pyplot.xlim()
and matplotlib.pyplot.ylim()
. However the color-bar does not scale according to the magnitude of the function in that region.
Following is my code:
import matplotlib.pyplot as plt
from dolfin import *
from mshr import *
import logging
# mesh = Mesh("../meshes/annulus_refined.xml")
centre = Point(0,0)
ro = 1000.0
ri = 1.0
domain = Circle(centre,ro)
cylinder = Circle(centre,ri)
channel = domain-cylinder
mesh = generate_mesh(channel,100)
s = FiniteElement("P", mesh.ufl_cell(), 1)
W = FunctionSpace(mesh,s)
cs = interpolate(Expression("cos(atan2(x[1],x[0]))",degree=3),W)
r = interpolate(Expression("sqrt(x[0]*x[0] + x[1]*x[1])",degree = 3),W)
phi_exact = project(-(r - (1/r))*cs,W)
c = plot(phi_exact)
plt.colorbar(c)
plt.xlim([-3,3])
plt.ylim([-3,3])
Following is the plot I obtain:
Are there any other ways to zoom into the plot such that color-bar scales appropriately? Any suggestions would be greatly appreciated.