0

I have a function that creates a Holoviewa heatmap. If I save the heatmap using hv.save(heatmap, 'heatmap.html') it works great! I just cannot figure out how to show the plot without having to save it. The same script generates two density plots with Plotly and using .show() and pops the plot up in my browser.

I am NOT using jupyter notebook and have been starting the bokeh server from a DOS prompt. I am working inside PyCharm Community with Python 3.10. Though if I could do it all from inside the script that would be easier.

def gen_heat_map(df: pandas.DataFrame, freq: float) -> holoviews.HeatMap:
    """
    Uses a single frequency upon which to build the heatmap.

    :param df: pandas.Dataframe containing data read from a JSON file
    :param freq: The frequency to build the heatmap out of
    :return: Holoviews Heat Map
    """
    # Select a single frequency upon which to build the heatmap
    single_frq = df[df.centerFrequency == freq].reset_index(drop=True)

    # create a second dataframe from each transmission
    sec_df = pd.DataFrame()
    for index, row in single_frq.iterrows():
        sec_df = sec_df.append(make_by_second(row), ignore_index=True)

    min_df = sec_df.set_index('time').resample('1min').mean().reset_index().replace(np.nan, -160)
    with pd.option_context('display.max_columns', None):
        print(min_df)

    min_df["Minute"] = min_df["time"].dt.strftime("%M")
    min_df["Hour"] = min_df['time'].dt.strftime("%H")

    heatmap = hv.HeatMap(min_df, ['Minute', 'Hour'], ['power', 'time'])
    heatmap.opts(radial=True,
                 width=750,
                 height=750,
                 tools=['hover'],
                 colorbar=True,
                 cmap='bokeh',
                 start_angle=-np.pi * 7 / 24,
                 title='Frequency Power Level Radial Heat Map'
                 )
    return heatmap

heatmap = gen_heat_map(df, 929612500.0)

The function gen_heat_map takes a large Pandas Dataframe of data read from a JSON file plus a single frequency and generates the heat map. It is trying to display this resultant heat map that is the issue. I can do so through Holoviz's Panel toolkit but I would like to find a simpler solution.

Suggestions?

Thanks, Doug

AeroClassics
  • 1,074
  • 9
  • 19
  • A little more details about your setup would be good. Are working in an interactive environment? Jupyter lab? Executing scripts from the CLI? – Paul H Aug 18 '22 at 22:18
  • Sorry, please see updated question. – AeroClassics Aug 19 '22 at 18:25
  • I'm not quite sure what the question is, but https://stackoverflow.com/questions/45308714/holoview-with-bokeh-does-not-show-plots might have the answer. – James A. Bednar Aug 19 '22 at 18:37
  • Show us some code that demonstrates the problem. As it stands, you're not making it easy for volunteers to try things. https://stackoverflow.com/help/minimal-reproducible-example – J_H Aug 19 '22 at 18:38
  • I understand that you would like code. I will add it. Though, I thought the question was pretty straight forward. I create a holoviews.element.raster.Heatmap and I am trying to figure out how to display it on the screen within the app. – AeroClassics Aug 22 '22 at 14:54

0 Answers0