How to add spacing between columns in a heatmap?

7 visualizaciones (últimos 30 días)
zhehao.nkd
zhehao.nkd el 30 de Jun. de 2023
Comentada: Adam Danz el 30 de Jun. de 2023
Hello, I'm looking for a way to add spacing between columns of a heatmap ( show each column separately with some distance). It seems that there is no built-in functions to add spacing with heatmap objects. Is there any other possible way to do that?

Respuestas (1)

Saurabh
Saurabh el 30 de Jun. de 2023
Editada: Saurabh el 30 de Jun. de 2023
If you want to add spacing between columns of a heatmap in MATLAB, you are correct that there is no direct built-in function to achieve this with the heatmap object. However, you can use an alternative approach to create the desired spacing effect. Here's a possible solution:
1. Create a matrix with spacing: Start by creating a new matrix that includes additional columns to represent the desired spacing between the original columns of your heatmap. You can achieve this by inserting empty columns or columns with NaN values in the appropriate positions.
2. Plot the modified matrix: Use the `imagesc` function to plot the modified matrix instead of the heatmap object. The `imagesc` function creates a heatmap-like visualization, allowing you to customize the appearance further.
3. Adjust the axes and labels: Since you are using `imagesc`, you will need to adjust the axes and labels manually. Set the x-axis tick locations and labels to match the positions of the original columns. You can use the `xticks` and `xticklabels` functions for this purpose.
4. Customize the colormap and colorbar: If desired, you can customize the colormap and colorbar of the `imagesc` plot to match the original heatmap. Use the `colormap` and `colorbar` functions to modify the appearance of the color scale.
IF THIS WAS HELPFUL, PLEASE ACCEPT THE ANSWER
Here's an example code snippet to illustrate this approach:
%matlab
% Original heatmap data
data = rand(5, 4); % Example data,
  1 comentario
Adam Danz
Adam Danz el 30 de Jun. de 2023
@Saurabh perhaps you could add an example that demonstrates steps 1 and 3 since those are the trickier steps.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by