Matlab plot transparent

Matlab plot transparent DEFAULT

Basic 'plot' function markers do not currently support transparency or alpha values. If you would like to make a scatter plot with transparent markers, it is suggested that you use the 'scatter' function and use either 'alpha' or set the value of the property 'MarkerFaceAlpha':

 

scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k'); % Set property MarkerFaceAlpha and MarkerEdgeAlpha to <1.0 scatter1.MarkerFaceAlpha = .2; scatter1.MarkerEdgeAlpha = .2;

or:

 

scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k'); alpha(scatter1,.2)

If you would like to have a line plot using 'plot' with transparent markers on top, you can simply use 'hold on/off' and 'scatter' in conjunction for the same desired effect:

plot(x,y); hold on scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k'); scatter1.MarkerFaceAlpha = .2; hold off

You can also change the transparency of the lines generated by 'plot' by appending the 'Color' property with an alpha value:

plot1 = plot(x,y); plot1.Color(4) = 0.2;

Please see the "Input Arguments" list for the property 'value' on the documentation page for 'alpha' for a list of graphics objects that support face transparency:

Sours: https://www.matlabsolutions.com/resources/how-can-i-make-the-plot-function-markers-and-lines-transparent-using-alpha-or-otherwise-.php

How to make '.' Markers transparent in a Scatter plot?

Hello

Just tested this in R2019a and it works as for you, I have not yet upgraded to 2020.

Just an idea, try to grab the handle of the scatter plot

>> hs=scatter(x, y, 'Marker', '.');

Then you can investigate the properties of the handles directly, type hs. and then tab and a window with all the properties will appear, scroll down, in my case I found MarkerEdgeAlpha:

>> hs.MarkerEdgeAlpha

ans =

1

Which I could modify like this

>> hs.MarkerEdgeAlpha=0.5

hs =

Scatter with properties:

Marker: '.'

MarkerEdgeColor: 'flat'

MarkerFaceColor: 'none'

SizeData: 36

LineWidth: 0.5000

XData: [1×10000 double]

YData: [1×10000 double]

ZData: [1×0 double]

CData: [0 0.4470 0.7410]

Show all properties

>>

Perhaps you have to modify hs.MarkerFaceAlpha as well?

Hope that helps.

Sours: https://www.mathworks.com/matlabcentral/answers/724388-how-to-make-markers-transparent-in-a-scatter-plot
  1. Sisense user roles
  2. Iple house
  3. Water lettuce petsmart
  4. Obituary columbia sc

alpha

Main Content

Description

example

sets the face transparency for objects in the current axes that support transparency. Specify as or , or as a number in the range [0, 1]. A value of makes the objects transparent, and value of makes the objects fully opaque.

example

varies the transparency across all image, patch, surface, and scatter objects in the axes. This option sets the corresponding alpha data properties for the objects.

controls the transparency of the faces for patch, surface, and scatter objects in the axes. This option sets the on patch and surface objects. For scatter objects, it sets the and properties.

example

controls the interpretation of the alpha data values for all image, patch, surface, and scatter objects in the axes. This option sets the property on the objects.

example

sets the transparency for the objects specified by . The option, , can precede any of the input arguments in the previous syntaxes. Use single quotes around input arguments that are character arrays, for example, .

sets the transparency for the objects in the axes specified by , instead of the current axes. Specify as the first input argument. You cannot specify both the and inputs.

Examples

collapse all

Set Transparency for All Graphics Objects in Axes

Create a bar chart and a scatter chart. Set the face transparency for both the bar series and scatter series object to .

bar(1:10) hold on scatter(10*rand(10,1),10*rand(10,1),'filled','SizeData',200) hold off alpha(.5)

Set Transparency for Specific Graphics Object

Create a bar chart and a scatter chart. Set the transparency for the scatter series object to without affecting the bar series object.

b = bar(1:10); hold on s = scatter(10*rand(10,1),10*rand(10,1),'filled','SizeData',200); hold off alpha(s,.5)

Set Surface Transparency Using z Values

Create a surface chart. Vary the transparency across the surface based on the z values.

s = surf(peaks); alpha(s,'z')

Set Mapping of Alpha Data into Alphamap

Create an image. Vary the transparency across the image based on the color values. By default, the image clamps the transparency values between 0 and 1. Values less than 0 are completely transparency and values greater than 1 are completely opaque. Instead, transform the transparency values to span the alphamap using the command.

imagesc(peaks) alpha color alpha scaled

Input Arguments

collapse all

— Face transparency value
number in the range [0, 1] | |

Face transparency value, specified as one of these values:

  • Number in the range [0, 1] — Set the face transparency to the specified value. A value of 0 means transparent. A value of 1 means opaque. Values between 0 and 1 are partially transparent.

  • — Set the face transparency to 0 (transparent).

  • — Set the face transparency to 1 (opaque).

If the object does not have a face or if the face has no color, then the function does not have a visual effect on the object. For example, does not have a visual effect on scatter objects that use unfilled markers or that use markers without a face (, , , and ).

This table lists the graphics objects that support transparency and the associated face transparency properties that updates to the value specified.

— Option to vary transparency across object
| | | | | vector or matrix

Option to vary the transparency across the object, specified as one of the values in this table. The table columns indicate how each option affects the different types of objects, depending on what objects are contained in the axes.

OptionSurface ObjectsScatter ObjectsPatch ObjectsImage Objects
Sets the property to be the same as the property and sets the property to . Sets the property to be the same as the property and sets the and properties to .Sets the property to be the same as the property and sets the property to . No effect.
Sets the property to be the same as the property and sets the property to . Sets the property to be the same as the property and sets the and properties to .Sets the property to be the same as the property and sets the property to . No effect.
Sets the property to be the same as the property and sets the property to . Sets the property to be the same as the property and sets the and properties to .Sets the property to be the same as the property and sets the property to . No effect.
Sets the property to be the same as the property and sets the property to . Sets the property to be the same as the property and sets the and properties to . Sets the property to be the same as the property and sets the property to . Sets the data property to be the same as the property.
Sets the property to a matrix of random numbers the same size as the property and sets the property to . Sets the property to a matrix of random numbers the same size as the property and sets the and properties to . Sets the property to a matrix of random numbers the same size as the property and sets the property to . Sets the data property to a matrix of random numbers the same size as the property.

Create a vector or matrix , and use the function form of the command. For example:

A = [.1 .2; .3 .4] alpha(A)
Specify as a matrix that is the same size as the property of the surface. The function sets the property to and sets the property to .Specify as a vector that is the same size as the property of the scatter object. The function sets the property to and sets the and properties to . Specify as a matrix that is the same size as the property of the patch. The function sets the property to and sets the property to .Specify as a matrix that is the same size as the property of the image. The function sets the data property to .

— Option for flat or interpolated face transparency
| |

Option for flat or interpolated face transparency, specified as one of the values in this table. The table columns indicate how each option affects the different types of objects, depending on what objects are contained in the axes.

OptionSurface ObjectsScatter ObjectsPatch Objects
Sets the property to . The property must be an array the same size as the property. The property must be set to .Sets the and properties to . The property must be a vector the same size as the property. The property must be set to .Sets the property to . The property must be a column vector with length equal to the number of faces in the property.
Sets the property to . The property must be an array the same size as the property. The property must be set to .No effect.Sets the property to . The property must be a column vector with length equal to the number of vertices in the property.
Sets the property to . The property must be set to .No effect.No effect.

— Interpretation of alpha data values
| |

Interpretation of alpha data values, specified as , , or . This option sets the property for image, patch, surface, and scatter objects in the axes.

  • — Interpret alpha data values as transparency values. A value of 0 or less is completely transparent. A value of 1 or greater is opaque. Values between 0 and 1 are semitransparent.

  • — Interpret the values as indices into the figure’s alphamap. Fix values with a decimal portion to the nearest lower integer. The property of the figure contains the alphamap.

  • — Transform the alpha data values to span the portion of the figure’s alphamap indicated by the property of the axes. Linearly map the data values to alpha values.

— Graphics objects that support transparency
scalar | vector

Graphics objects that support transparency, specified as a scalar or vector. Use this option if you want to control which objects affects. Otherwise, affects all objects in the axes that support transparency.

Specify one or more of these types of objects:

  • Area object

  • Bar series object

  • Scatter series object

  • Histogram or histogram2 object

  • Image object

  • Patch object

  • Chart or primitive surface object

Note

Not all objects support the , , and input arguments. See the syntax descriptions for a list of objects that each option supports.

— Axes object
axes object

Axes object. If you do not specify the axes, then sets the transparency for graphics objects in the current axes.

Compatibility Considerations

expand all

Scatter Objects Change When You Specify the , , or arguments

Behavior changed in R2020b

Starting in R2020b, objects in the axes are affected when you call the function with the , , or arguments without specifying a particular object within the axes to modify.

In R2020a and earlier releases, the , , and arguments have no effect on objects in the axes.

For example, this code creates a surface plot and a scatter plot, and then calls the function to vary the transparency along the x-dimension. In R2020a, only the surface plot changes when you call the function. In R2020b, both plots are affected.

[X,Y] = meshgrid(-10:10); Z = ones(21,21) * -2; surf(X,Y,Z) hold on scatter([-8 2 4 -5 5 3],[7 4 2 -1 -7 0],200,'filled') alpha('x')

To prevent objects from changing, specify the object to modify as the first argument to the function. For example, to update the preceding code, call the function with an output argument . Then pass to the function to modify only the object.

[X,Y] = meshgrid(-10:10); Z = ones(21,21) * -2; s = surf(X,Y,Z) hold on scatter([-8 2 4 -5 5 3],[7 4 2 -1 -7 0],200,'filled') alpha(s,'x')

Introduced before R2006a

You have a modified version of this example. Do you want to open this example with your edits?

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Contact your local office

Sours: https://www.mathworks.com/help/matlab/ref/alpha.html
HOW TO: Export MATLAB Plots the Right Way

MATLAB: How to make the ‘plot’ function markers and lines transparent using ‘alpha’ or otherwise

Basic 'plot' function markers do not currently support transparency or alpha values. If you would like to make a scatter plot with transparent markers, it is suggested that you use the 'scatter' function and use either 'alpha' or set the value of the property 'MarkerFaceAlpha':
If you would like to have a line plot using 'plot' with transparent markers on top, you can simply use 'hold on/off' and 'scatter' in conjunction for the same desired effect:
You can also change the transparency of the lines generated by 'plot' by appending the 'Color' property with an alpha value:
Please see the "Input Arguments" list for the property 'value' on the documentation page for 'alpha' for a list of graphics objects that support face transparency:
Sours: https://itectec.com/matlab/matlab-how-to-make-the-plot-function-markers-and-lines-transparent-using-alpha-or-otherwise/

Transparent matlab plot

How can I make the 'plot' function markers and lines transparent using 'alpha' or otherwise?

Basic 'plot' function markers do not currently support transparency or alpha values. If you would like to make a scatter plot with transparent markers, it is suggested that you use the 'scatter' function and use either 'alpha' or set the value of the property 'MarkerFaceAlpha':

scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k');

scatter1.MarkerFaceAlpha = .2;

scatter1.MarkerEdgeAlpha = .2;

Or:

scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k');

alpha(scatter1,.2)

If you would like to have a line plot using 'plot' with transparent markers on top, you can simply use 'hold on/off' and 'scatter' in conjunction for the same desired effect:

plot(x,y);

hold on

scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k');

scatter1.MarkerFaceAlpha = .2;

hold off

Please see the "Input Arguments" list for the property 'value' on the documentation page for 'alpha' for a list of graphics objects that support face transparency:

https://www.mathworks.com/help/matlab/ref/alpha.html#buvaucs-5

Sours: https://www.mathworks.com/matlabcentral/answers/325258-how-can-i-make-the-plot-function-markers-and-lines-transparent-using-alpha-or-otherwise
MATLAB tutorial: Simple transparent graphics in MATLAB using alpha

Select a Web Site

Add Transparency to Graphics Objects

What Is Transparency?

The transparency of a graphics object determines the degree to which you can see through it. Add transparency to graphics objects to customize the look of your charts or reveal details about an object that are otherwise hidden. This table shows the difference between an opaque and semitransparent surface.

Opaque ObjectSemitransparent Object

Graphics Objects that Support Transparency

Control the transparency of an object using the function or by setting properties of the object related to transparency. Some graphics objects support using a different transparency value for the faces versus the edges of the object.

This table lists the objects that support transparency and the corresponding properties. Set the properties to a scalar value in the range . A value of 0 means completely transparent, a value of 1 means completely opaque, and values between 0 and 1 are semitransparent.

Tip

Patch, surface, scatter, and image objects support using alpha data to vary the transparency across the object. For more information, see Vary Transparency Using Alpha Data.

Create Area Chart with Transparency

Combine two semitransparent area charts by setting the and properties for each area object.

x = linspace(0,10); y1 = 4 + sin(x).*exp(0.1*x); area(x,y1,'FaceColor','b','FaceAlpha',.3,'EdgeAlpha',.3) y2 = 4 + cos(x).*exp(0.1*x); hold on area(x,y2,'FaceColor','r','FaceAlpha',.3,'EdgeAlpha',.3) hold off

Create Bar Chart with Transparency

Create a semitransparent bar chart by setting the property of the bar series object to a value between 0 and 1. Display the grid lines.

month = 1:5; sales = [10 25 85 35 16]; bar(month,sales,'FaceAlpha',.5) grid on

Create Scatter Chart with Transparency

Create a scatter plot using blue, semitransparent markers. Then, add a second scatter plot using red, semitransparent markers. Specify the marker color by setting the and properties of the scatter series object. Specify the transparency by setting the and properties to a scalar value between 0 and 1.

x = [5 10 11 13 18]; y1 = [40 80 150 80 50]; a1 = 100*[100 50 80 30 50]; scatter(x,y1,a1,'MarkerFaceColor','b','MarkerEdgeColor','b',...'MarkerFaceAlpha',.2,'MarkerEdgeAlpha',.2) axis([0 20 0 200]) x = [2 6 8 11 13]; y2 = [30 40 100 60 140]; a2 = 100*[30 50 30 80 80]; hold on scatter(x,y2,a2,'MarkerFaceColor','r','MarkerEdgeColor','r',...'MarkerFaceAlpha',.2,'MarkerEdgeAlpha',.2) hold off

Vary Transparency Using Alpha Data

Patch, surface, and image objects have a few additional properties for varying the transparency across the object.

  • Images — Specify a different transparency value for each image element. Specify the values by setting the property to an array the same size as the property.

  • Chart and primitive surfaces — Specify a different transparency value for each face and edge. Additionally, you can specify whether to use flat or interpolated transparency across each face or edge. First, specify the transparency values by setting the property to an array the same size as the property. Then, specify flat or interpolated transparency by setting the and properties to either or .

  • Patches — Specify a different transparency value for each face and edge. Additionally, you can specify whether to use flat or interpolated transparency across each face or edge. First, specify the transparency values by setting the property to a column vector with length equal to either the number of faces (for flat transparency) or the number of vertices in the patch (for interpolated transparency). Then, specify flat or interpolated transparency by setting the and properties to either or .

  • Scatter plots — Specify a different transparency value for each marker. First, specify the transparency values by setting the property to an array the same size as the property. Then, specify flat transparency by setting either the or property to .

Use the property to control how the objects interpret the alpha data values. See the property descriptions for more details.

Vary Surface Chart Transparency

Create a surface and vary the transparency based on the gradient of the data. Use a flat transparency across each surface face by setting the to . Set the surface color to blue to show how the transparency varies.

[x,y] = meshgrid(-2:.2:2); z = x.*exp(-x.^2-y.^2); a = gradient(z); surf(x,y,z,'AlphaData',a,...'FaceAlpha','flat',...'FaceColor','blue')

Vary Patch Object Transparency

Plot a line using the function. Set the last entry of to so that creates a line instead of a closed polygon.

Define one transparency value per vertex by setting the property to a column vector. Interpret the values as transparency values (0 is invisible, 1 is opaque) by setting the property to . Interpolate the transparency between vertices by setting the property to .

x = linspace(1,10,10); y = sin(x); y(end) = NaN; figure alpha_values = linspace(0,1,10)'; patch(x,y,'red','EdgeColor','red',...'FaceVertexAlphaData',alpha_values,'AlphaDataMapping','none',...'EdgeAlpha','interp')

See Also

| | | | | | | |

You have a modified version of this example. Do you want to open this example with your edits?

Sours: https://www.mathworks.com/help/matlab/creating_plots/add-transparency-to-graphics-objects.html

You will also be interested:

.



892 893 894 895 896