Creating a Random Surface Plot with HoloViews and NumPy

  • Share this:

Code introduction


This function creates a 3D surface plot using HoloViews, which generates random data with numpy and then plots the surface.


Technology Stack : numpy, holoviews

Code Type : 3 D surface map

Code Difficulty : Intermediate


                
                    
import numpy as np
import holoviews as hv
from holoviews import opts

def random_surface_plot(x, y):
    # Generate random data for a 3D surface plot
    z = np.sin(np.sqrt(x**2 + y**2))
    
    # Create a surface plot using HoloViews
    surface = hv.Surface((x, y, z)).relabel("Random Surface")
    
    # Set the plot options for better visualization
    plot = surfaceopts.Surface(colorbar=True, cmap='viridis')
    
    # Display the plot
    hv.show(plot)