How to use custom png image marker with plot?

Related searches

I would like to utilize customer markers in both scatter and line charts. How can I make custom marker out of a PNG file?

I don't believe matplotlib can customize markers like that. See here for the level of customization, which falls way short of what you need.

As an alternative, I've coded up this kludge which uses figimage to place images at the line point locations.

import matplotlib.pyplot as plt
import matplotlib.image as image

# constant
dpi = 72
# read in our png file
im = image.imread('smile.png')
image_size = im.shape[1], im.shape[0]

fig = plt.figure(dpi=dpi)
ax = fig.add_subplot(111)
# plot our line with transparent markers, and markersize the size of our image
line, = ax.plot((1,2,3,4),(1,2,3,4),"bo",mfc="None",mec="None",markersize=imageSize[0] * (dpi/ 96))
# we need to make the frame transparent so the image can be seen
# only in trunk can you put the image on top of the plot, see this link:

# translate point positions to pixel positions
# figimage needs pixels not points
path, affine = line._transformed_path.get_transformed_points_and_affine()
path = affine.transform_path(path)
for pixelPoint in path.vertices:
    # place image at point, centering it


How to add custom images as markers?, markers?. Learn more about plotting, marker, inset image into plot. y2 = cos( 2*pi*x/0.7);. plot(ax1, x, y2, 'r-', 'LineWidth', 2);. Capture.PNG� plot (x, y1, 'LineWidth', 2) grid on; ax1 = gca; % Store handle to axes 1. % Create smaller axes in top right, and plot on it. % Store handle to axes 2 in ax2. ax2 = axes ('Position', [.6 .6 .3 .3]) box on; fileName = 'peppers.png'; rgbImage = imread (fileName);

Following on from Mark's answer. I just thought I would add to this a bit because I tried to run this and it does what I want with the exception of actually displaying the icons on the graph. Maybe something has changed with matplotlib. It has been 4 years.

The line of code that reads:


does not seem to work, however


does work.

Images/SVG/Custom Icons Scatter-mapbox - Dash, Hello community, I've drawn a scattermap with points as marker, but my client you could use layout images as described in, and TileLayer(url="{z}/{x}/{y}.png")] +� Clarification: The images were all transperant but since I was overlaying it over another image it turned the current images background to default black. I posted a solution to this problem which I guess would be really useful to a lot of people.

The other answer may lead to problems when resizing the figure. Here is a different approach, positionning the images inside annotation boxes, which are anchored in data coordinates.

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.offsetbox import OffsetImage, AnnotationBbox

path = ""
image = plt.imread(path)[116:116+30, 236:236+30]

x = np.arange(10)
y = np.random.rand(10)

fig, ax = plt.subplots()

def plot_images(x, y, image, ax=None):
    ax = ax or plt.gca()

    for xi, yi in zip(x,y):
        im = OffsetImage(image, zoom=72/ax.figure.dpi)
        im.image.axes = ax

        ab = AnnotationBbox(im, (xi,yi), frameon=False, pad=0.0,)


plot_images(x, y, image, ax=ax)

Custom png image marker not displaying in a sto, At the moment, this is a known issue that the custom PNG that you're using is failing to be fetched from the resource. If you want to show case the� Custom Transparent PNG Map Pin (106x106) I made this image a transparent PNG, 106x106 pixels (you can make it any size you want but it is always good to optimize it for performance, i.e. if you

Importing a .png image as a custom marker in LaTeX - TeX, I am trying to create scatter plot using an input .dat file with custom markers ( which are saved as a .png file). If I do not use the custom markers� A background image can be added to the layout of a figure with fig.add_layout_image or by setting the images parameter of go.Layout. The source attribute of a go.layout.Image can be the URL of an image, or a PIL Image object (from PIL import Image; img ='filename.png')).

Add Custom Images as Markers, Click the picture icon next, and choose the image you just uploaded. Click Save. Note: the best way to size- width= 35 to 55 pixel; height= self scale. PNG files with � Customizing a map marker. The image below displays a Google maps marker with the default red icon. You can change this icon to an image of your choice. The table below explains the code that customizes the default marker to use an icon for parking lots.

MATLAB has a range of default symbols to use as point markers on a scatterplot (circle, asterisk, point, etc.). But is there any way of replacing these with a custom symbol? Specifically, I would like to give each point a thumbnail image representing the identity of that point.

  • I suggest this be marked as a duplicate of:…
  • Instead of png images one can check if there exist a fontset that contains an appropriate symbol, that could be used as marker. Either one could use standard utf8 symbols as in Matplotlib custom marker/symbol, or if a specific font is needed, an example would be in How to use Font Awesome symbol as marker in matplotlib.
  • AttributeError: 'AxesSubplot' object has no attribute 'get_frame'
  • See answer by t gillespie for handling get_frame error