logo
down
shadow

Equal bin sizes including border using mayavi imshow?


Equal bin sizes including border using mayavi imshow?

By : xiang eagle
Date : November 21 2020, 12:01 PM
it should still fix some issue I don't know how to do this the right way (it seems like it would be very difficult to get right from what I know about imshow), but I have a conceptual suggestion.
Represent your NxN matrix of items on the surface with an (N+2)x(N+2) matrix and set the border entries to be -1. Then make a customized colormap such that your desired colormap is contained between 0 and 1, with all other entries as (0,0,0,0). I'm not exactly sure how to do that -- iirc mayavi modules don't allow you to setup discontinuous color tables, but you could still hack it in this way. Let me know if the part about the color table is confusing, and I can provide some code to make it work.
code :


Share : facebook icon twitter icon
iOS- Including different image sizes for different display sizes

iOS- Including different image sizes for different display sizes


By : Da Huai
Date : March 29 2020, 07:55 AM
may help you . If you're on iOS 7 SDK which you most likely are, make use of the .xcassets catalogue. It has options for different screen sizes, put the different versions of your image there. And then load image in code.
How to draw a color image in mayavi (imshow)

How to draw a color image in mayavi (imshow)


By : user2008282
Date : March 29 2020, 07:55 AM
To fix the issue you can do Method
I had to make use of mayavi's custom colormaps, see http://docs.enthought.com/mayavi/mayavi/auto/example_custom_colormap.html .
code :
import pylab as pl
from mayavi import mlab

def mlab_imshowColor(im, alpha=255, **kwargs):
    """
    Plot a color image with mayavi.mlab.imshow.
    im is a ndarray with dim (n, m, 3) and scale (0->255]
    alpha is a single number or a ndarray with dim (n*m) and scale (0->255]
    **kwargs is passed onto mayavi.mlab.imshow(..., **kwargs)
    """
    try:
        alpha[0]
    except:
        alpha = pl.ones(im.shape[0] * im.shape[1]) * alpha
    if len(alpha.shape) != 1:
        alpha = alpha.flatten()

    # The lut is a Nx4 array, with the columns representing RGBA
    # (red, green, blue, alpha) coded with integers going from 0 to 255,
    # we create it by stacking all the pixles (r,g,b,alpha) as rows.
    myLut = pl.c_[im.reshape(-1, 3), alpha]
    myLutLookupArray = pl.arange(im.shape[0] * im.shape[1]).reshape(im.shape[0], im.shape[1])

    #We can display an color image by using mlab.imshow, a lut color list and a lut lookup table.
    theImshow = mlab.imshow(myLutLookupArray, colormap='binary', **kwargs) #temporary colormap
    theImshow.module_manager.scalar_lut_manager.lut.table = myLut
    mlab.draw()

    return theImshow

def test_mlab_imshowColor():
    """
    Test if mlab_imshowColor displays correctly by plotting the wikipedia png example image
    """

    #load a png with a scale 0->1 and four color channels (an extra alpha channel for transparency).
    from urllib import urlopen
    url = 'http://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png'
    im = pl.imread(urlopen(url), format='png')
    im *= 255

    mlab_imshowColor(im[:, :, :3], im[:, :, -1])

    mlab.points3d([-200, 300, -200, 300],
                  [-200, 300, 200, -300],
                  [300, 300, 300, 300])
    mlab.show()

if __name__ == "__main__":
    test_mlab_imshowColor()
Imshow - splitted with different pixel sizes

Imshow - splitted with different pixel sizes


By : Maider Ocerin
Date : March 29 2020, 07:55 AM
it fixes the issue This is way simpler if you just use a single axes object. Then also zooming will work flawlessly.
Code:
code :
from matplotlib import pyplot as plt
import numpy as np

# prepare the data
data = np.arange((100))
data = np.reshape(data, (10,10))
data1=data[0:5,:]
data2=data[5:10,:]

# create the figure and a single axis
fig, ax = plt.subplots()

# common arguments to imshow
kwargs = dict(
        origin='lower', interpolation='nearest', vmin=np.amin(data),
        vmax=np.amax(data), aspect='auto')

# draw the data
ax.imshow(data1, extent=[0, 10, 0, 5], **kwargs)
ax.imshow(data2, extent=[0, 10, 5, 7.5], **kwargs)

# optional black line between data1 and data2
ax.axhline(5, color='k')

# set the axis limits
ax.set_ylim(0, 7.5)
ax.set_xlim(0, 10)

# set the xticklabels
xticks = np.arange(0,10)
ax.set_xticks(xticks + 0.5)
ax.set_xticklabels(map(str, xticks))

# set the yticks and labels
yticks = np.concatenate((
        np.arange(0, 5) + 0.5,
        np.arange(5, 7.5, 0.5) + 0.25
        ))
ax.set_yticks(yticks)
ax.set_yticklabels(map(str, xticks))

# show the figure
plt.show()
Matplotlib imshow figure(2,2) image sizes proportional to axes

Matplotlib imshow figure(2,2) image sizes proportional to axes


By : NeRii SwaNd
Date : March 29 2020, 07:55 AM
This might help you In the code from the question, the subplot columns and rows are equal in width and height respectively. What you want is to make the first column and the first row 4 times larger than the second.
This can easily be accomplished using the gridspec's height_ratios and width_ratios.
code :
import matplotlib.pyplot as plt
import numpy as np

A = np.random.rand(500,500)

fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(7, 7),
                        gridspec_kw=dict(height_ratios=[4,1], width_ratios=[4,1]))
axs[0, 0].set_title('A')
axs[0, 0].imshow(A[:400,:400], vmin=0, vmax=1)
axs[0, 1].set_title('B')
axs[0, 1].imshow(A[:400,400:], vmin=0, vmax=1)
axs[1, 0].set_title('C')
axs[1, 0].imshow(A[400:,:400], vmin=0, vmax=1)
axs[1, 1].set_title('D')
axs[1, 1].imshow(A[400:,400:], vmin=0, vmax=1)
plt.show()
Border with equal sizes on all 4 sides of JTextpane

Border with equal sizes on all 4 sides of JTextpane


By : H-Gn
Date : March 29 2020, 07:55 AM
will be helpful for those in need I am setting a createLineborder to my JTextPane. But the border lines are little different in right-end and bottom of JTextpane when compared to Left-end and top of TextPane. I searched in net and I found that it is the default behavior of lineborder. So can anyone please tell me that is there any border which gives equal lines sizes in all 4 sides? , I would say it has more to do with using null layouts...
Related Posts Related Posts :
  • Filtering from data
  • Where is the problem about selenium with python?
  • ansible custom filter fails when importing python library
  • How to assign the label of one column to the new one based on group maximum in pandas
  • What is the best approach for isolating a single area of similar colour?
  • Creating multiple clients for topics
  • Why is my 'for loop', despite iterating over all keys, only acting on the last one?
  • Can someone tell me what's wrong, when I run it the browsers says "This site can’t be reached"
  • Error in setting up mitmproxy on alpine 3.9
  • From traditional loop to list comprehension
  • Django celery unregistered task | relative imports
  • How to add elements in a multi dimensional array
  • Async await with sqs receive messages not working properly
  • What is definition of 'NAME' in Python grammar
  • Easy method to move rows from df to another with coditions?
  • Changing the size of only a single plot in matplotlib, without altering figure parameters
  • Fastest way to use Vision API on 10,000+ images with python
  • How to install nvidia apex on Google Colab
  • Random numbers Continuous in python
  • Fetching data after a certain time interval(10 sec) from a continuously increasing database like mysql using flask
  • Using VLOOKUP with merge in Python
  • Calculate geographical distance between 5 cities with all the possible combinations of each city
  • How to filter a pandas dataframe using multiple partial strings?
  • Pygame- make bullet shoot toward cursor direction
  • Create SEQUENCE based dictionary from list
  • How to fix broken link from Django MEDIA_ROOT?
  • How can I display the current time left in a timer in a label?
  • Compute number of occurance of each value and Sum another column in Pandas
  • How to separate the prefix in words that are 'di'?
  • Handling network errors from an external API across an application
  • Want a pandas Series of Trips Completed to count(Request) ratio for each hour as index for the given dataframe
  • Access dict keys and list elements by same index to loop over and assign values
  • Find rows from the same dataframe based on condition
  • Read only specific part first two lines from text file in python
  • Python How to convert string to dataframe?
  • How to fix this my error code program? I use Python 3.6
  • Is there a way of getting this string down to 3 words?
  • Large difference between overall F Score for a custom Spacy NER model and Individual Entity F Score
  • Drop rows where timestamps are older than subsequent row
  • Implement a bottle spin
  • Unable to convert widows epoch time to normal date time
  • Values from a XML file
  • PyAudio readframes not ending when wav file completes
  • Could not load the module
  • How to change datetime.datetime(2012, 1, 1, 0, 0) to 1/1/2012 in Python?
  • How to create ASN.1 Sequence without NamedType?
  • How to locate specific sequences of words in a sentence efficiently
  • How can I generate a multi-step process in Django without changing pages (w/out a new request)?
  • Why does this list comprehension only "sometimes" work?
  • send html report with row collapsed
  • How to define a type hint to a argument (the argument's value is a class, all expected value is a subclass of a certain
  • How do I send a styled pandas DataFrame by e-mail without losing the format?
  • How to view/average a groupby dataframe when the data is a string?
  • Django 2.2 staticfiles do not work in development
  • Flag to enable/disable numba JIT compilation?
  • Trying to split byte in a byte array into two nibbles
  • Error in Query - missing FROM-clause entry for table - SQL
  • Reading double c structures of Dll with Ctypes in Python
  • Autofill missing row in database based on missing time range
  • Get the max of a nested dictionary
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org