Plotting transparent histogram with non transparent edge

plt.hist accepts additional keyword arguments that are passed to the constructor for matplotlib.patches.Patch. In particular you can pass an fc= argument which lets you set the patch facecolor using an (R, G, B, A) tuple when you create the histograms. Changing the alpha value of the facecolor does not affect the transparency of the edges: …

Read more

colorWithAlphaComponent example in Swift

It’s not strange, it’s behaving exactly as it should. Although many of UIColor’s methods are class methods, there are still a few instance methods, and this is one of them. From the UIColor documentation. colorWithAlphaComponent: Creates and returns a color object that has the same color space and component values as the receiver, but has …

Read more

Individual alpha values in scatter plot

New solution with matplotlib >= 3.4 Since matplotlib 3.4, alpha supports an iterable of multiple values: https://matplotlib.org/stable/users/prev_whats_new/whats_new_3.4.0.html#transparency-alpha-can-be-set-as-an-array-in-collections import numpy as np import matplotlib.pylab as plt x = np.arange(10) y = np.arange(10) alphas = np.linspace(0.1, 1, 10) plt.scatter(x, y, alpha=alphas) plt.show() Old solution for matplotlib < 3.4 tcaswell’s suggestion is correct, you can do it like …

Read more

Any way to make plot points in scatterplot more transparent in R?

Otherwise, you have function alpha in package scales in which you can directly input your vector of colors (even if they are factors as in your example): library(scales) cols <- cut(z, 6, labels = c(“pink”, “red”, “yellow”, “blue”, “green”, “purple”)) plot(x, y, main= “Fragment recruitment plot – FR-HIT”, ylab = “Percent identity”, xlab = “Base …

Read more

How to set the opacity/alpha of a UIImage?

I just needed to do this, but thought Steven’s solution would be slow. This should hopefully use graphics HW. Create a category on UIImage: – (UIImage *)imageByApplyingAlpha:(CGFloat) alpha { UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGRect area = CGRectMake(0, 0, self.size.width, self.size.height); CGContextScaleCTM(ctx, 1, -1); CGContextTranslateCTM(ctx, 0, -area.size.height); CGContextSetBlendMode(ctx, kCGBlendModeMultiply); CGContextSetAlpha(ctx, alpha); CGContextDrawImage(ctx, area, …

Read more