Search code examples
plot3dgnuplotvector-graphics

3D vector field


I need help plotting a vector field in 3D, my problem is that I have a table with

x, y, z, Vx, Vy, Vz

These are the position and components of each vector, the vectors are normalized so its magnitude is one, and this is the problem because the unit cell on which my vectors are centered is a cube of side 5nm. And from this follow that drawing a vector with magnitude 1 on a cell so small won't work.

So my question is, how can I normalize the vectors to the size of the cell if this is possible??


Solution

  • I'm not sure whether I fully understand your problem. Please provide more information, data and some code.

    My guess: you want to scale the length of your vector by factor 5 (or maybe 5e-9?). Please clarify.

    Code:

    ### scale vectors
    reset session
    set view equal xyz
    
    # example data
    $Data <<EOD
    0.0 0.0 0.0 1.0000 0.0000 0.0000
    0.0 0.0 0.0 0.0000 1.0000 0.0000
    0.0 0.0 0.0 0.7071 0.7071 0.0000
    0.0 0.0 0.0 0.5773 0.5773 0.5773
    EOD
    
    myFactor = 5    # or do you mean 5e-9 ???
    set view 70,45
    
    splot $Data u 1:2:3:($4*myFactor):($5*myFactor):($6*myFactor) w vectors notitle
    
    ### end of code
    

    Result:

    enter image description here