Skip to content

Issues passing from scatter to tricontourf #27738

Open
@tvirazel

Description

@tvirazel

Hi everyone,

I am not that familiar in using the function tricontourf. I would need help understanding what I am doing wrong.
So basically, from an external FEM software, I am getting datas from a line of nodes:

  • x coordinates of these nodes (that I need to plot in the x axis) X_coord.csv
  • time steps of the simulation (that I need to plot in the y axis) time.csv
  • stress (that should give the color of the plot) stress.csv

I managed to get a first glimpse of what I want my final plot to look like using: matplotlib.pyplot.scatter. That gives:
scatter

However, I would the plot to be continuous and for that I tried to use: matplotlib.tri.tricontourf. That gives:
tricontourf

Do you from where are coming this pattern of vertical lines? Do you know how can I improve my basic code to have something that looks better? The big yellow part (that should be white) in the tricontourf around 0.04 is not that problematic since I can plot the two parts (left and rigth parts) separately but if you have any improvement on that side, you are welcome!

Here is my code:

import matplotlib.pyplot as plt
import numpy as np

X=np.loadtxt(r'....\X_coord.csv')
Y=np.loadtxt(r'....\time.csv')
S33=np.loadtxt(r'....\stress.csv')

fig, ax1 = plt.subplots(nrows=1)
test=ax1.tricontourf( X ,Y ,S33 ,levels=1000, cmap="viridis")
ax1.scatter(X,Y,c=S33,cmap='viridis',vmin=-5000, vmax=100,s=5)

fig.colorbar(test, ax=ax1)
ax1.set(xlim=(-0.003, 0.08), ylim=(-4e-10, 1.3e-8))

Thanks in advance,
Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions