Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • wdata wdata
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4
    • Issues 4
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • wtools
  • wdatawdata
  • Wiki
    • Examples
  • Python examples

Python examples · Changes

Page history
Update Python examples authored Feb 01, 2022 by Gabriel Wlazłowski's avatar Gabriel Wlazłowski
Hide whitespace changes
Inline Side-by-side
Examples/Python-examples.md
View page @ 1e72479a
...@@ -132,4 +132,32 @@ fig.savefig("velocity.png") ...@@ -132,4 +132,32 @@ fig.savefig("velocity.png")
plt.show() plt.show()
``` ```
Output Output
![velocity](uploads/a7f74f745d9abda5630bac010ca1b666/velocity.png) ![velocity](uploads/a7f74f745d9abda5630bac010ca1b666/velocity.png)
\ No newline at end of file
# Density and order parameter on the same plot - 1D case
```python
import numpy as np
import matplotlib.pyplot as plt
from wdata.io import WData, Var
# I read data directly from dwarf,
# Before running the script I mounted file system:
# sshfs gabrielw@dwarf.if.pw.edu.pl:/home2/ /home/gabrielw/home2-dwarf/
fwtxt="/home/gabrielw/home2-dwarf/scratch/loff-vortex/cold-atoms/st-two-vortices/DyK_120.wtxt"
data = WData.load(fwtxt)
fig, ax = plt.subplots()
ax.plot(data.xyz[0], data.rho_a[-1], color='red', label=r'$n_a$', lw=3.0) # plot last frame [-1]
ax.plot(data.xyz[0], data.rho_b[-1], color='blue', label=r'$n_b$', lw=3.0) # plot last frame [-1]
ax.set(xlabel='x', ylabel=r'$n(x)$')
ax2 = ax.twinx() # instantiate a second axes that shares the same x-axis
ax2.plot(data.xyz[0], np.abs(data.delta)[-1], color='black', label=r'$\Delta$', lw=2.0, ls="--") # plot last frame [-1]
ax2.set(ylabel=r'$\Delta(x)$')
fig.legend(loc="upper right", bbox_to_anchor=(1,1), bbox_transform=ax.transAxes)
fig.savefig("plot.png")
```
![plot](uploads/fff8b291bcc4ecb0ce2b22afb9a778fc/plot.png)
\ No newline at end of file
Clone repository
  • Data types
  • Examples
    • C examples
    • Python examples
  • Tags
  • VisIt plugin compilation
  • Visit integration
  • Home
  • wdata format concept