Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alisterburt/04f10fc59c4999ee89101fce5ffa2a10 to your computer and use it in GitHub Desktop.
Save alisterburt/04f10fc59c4999ee89101fce5ffa2a10 to your computer and use it in GitHub Desktop.
plot relion euler angle distribution on stereonet
#!/usr/bin/env python
import click
import starfile
import matplotlib.pyplot as plt
import mplstereonet
@click.command()
@click.option('--star_file', '-s', prompt='Input STAR file', type=click.Path(exists=True))
def star_orientation_distribution(star_file):
star = starfile.read(star_file)
theta = star['rlnAngleRot']
r = star['rlnAngleTilt']
fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(111, projection='stereonet')
ax.density_contourf(theta, r, measurement='poles', cmap='Blues', gridsize=100, sigma=5)
ax.grid()
ax.set(azimuth_ticklabels=[])
output_filename = str(star_file).replace('.star', '_orientation_distribution.svg')
fig.savefig(output_filename, transparent=True)
return
if __name__ == '__main__':
star_orientation_distribution()
@shahpnmlab
Copy link

Would this be the right way to add angular information to the plot?

ax.set(azimuth_ticklabels=[0,90,180,270,360,-270,-180,-90])

@alisterburt
Copy link
Author

I'm not sure exactly, which is why I removed them I just know that ax.density_contourf seemed to either change the ticklabels or rescale/shift the data somehow because the ticklabels didn't match my original data ranges - I'd love to know the answer if you end up looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment