Why matlab skips 2nd half of labels? - matlab

Here is a pretty streightforward code for displaying matrix in scaled color using imagesc command. The problem is that final figure has wrong labeling and doesnt show 2nd half of labels(it should be from 1 to 21, but it is from 1 to 10)
figure;
imagesc(magic(21));
set(gca,'XTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})
set(gca,'YTickLabel',{'1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21'})
I am using Ubuntu 16.04 and Matlab 2016b.

You set up the label text, but not the location, thus it will automatically put label locations and then substitute their text.
To set up the locations of the labels, first do:
set(gca,'XTick',...)
Then you can write in those labels whatever you preffer:
set(gca,'XTickLabel',{'banana', 'platano', 'potato',... })

You have to assign locations for those ticks, not just add labels.
figure;
imagesc(magic(21));
ax1 = gca;
ax1.YTick = 1:21;
ax1.XTick = 1:21;
ax1.XTickLabels = {'One','Two','Three',...
ax1.YTickLabels = {'Red','Brown','Green',...
Also since Matlab 2014b Mathworks created a new graphics system. You can access your graphics as objects directly instead of using set and get everywhere.

You can test this:
imagesc(magic(21));
set(gca,'XLim',[1 21])
set(gca,'XTick',[1:1:21])
set(gca,'XTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})
set(gca,'YLim',[1 21])
set(gca,'YTick',[1:1:21])
set(gca,'YTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})

Related

Dash, circular callback inputs

I have a problem with an application I want to code with Dash. I have two different checklists (indicator A, indicator B). My goal is that the user can choose multiple options for only one indicator. So it is allowed to choose a,b,c and 1. It should also be possible to select c and 2,3 at the same time. The selection of a,c and 1,2 on the other hand, should be prevented. My approach to this is the following code:
app.layout = html.Div([
html.Label('indicator A'),
dcc.Checklist(
id = 'i_a',
options=[
{'label': 'a', 'value': 'a'},
{'label': 'b', 'value': 'b'},
{'label': 'c', 'value': 'c'}
],
value = ['a']
),
html.Label('indicator B'),
dcc.Checklist(
id='i_b',
options=[
{'label': '1', 'value': '1'},
{'label': '2', 'value': '2'},
{'label': '3', 'value': '3'}
],
value=['1']
),
])
#app.callback(
Output('i_b', 'value'),
Input('i_a', 'value')
)
def change_b(value_a):
return ['1']
#app.callback(
Output('i_a', 'value'),
Input('i_b', 'value')
)
def change_b(value_b):
return ['a']
This creates an endless loop because the callbacks trigger each other. However, I have no idea how to solve the problem. I am grateful for any help :)
I think what you need is the new circular callbacks ability. Check out the examples on this page, which I think are very similar to what you're doing.

Unable to save address after data migration

One or more input exceptions have occurred.
"postcode" is required. Enter and try again.
"countryId" is required. Enter and try again.
I'm filling these values in my account edit address page, but facing this issue.
https://prnt.sc/u95nez
During migration, there is a problem with the loss postcode and telephone attributes values from customer_form_attribute and eav_form_element tables.
Adding missing values might help:
INSERT INTO customer_form_attribute (form_code, attribute_id)
VALUES ('adminhtml_customer_address', '33'),
('customer_address_edit', '33'),
('customer_register_address', '33'),
('adminhtml_customer_address', '34'),
('customer_address_edit', '34'),
('customer_register_address', '34');
INSERT INTO eav_form_element (element_id, type_id, fieldset_id, attribute_id, sort_order)
VALUES (NULL, '1', NULL, '33', '7'),
(NULL, '2', NULL, '33', '7'),
(NULL, '3', NULL, '33', '6'),
(NULL, '4', NULL, '33', '6'),
(NULL, '1', NULL, '34', '9'),
(NULL, '2', NULL, '34', '9'),
(NULL, '3', NULL, '34', '8'),
(NULL, '4', NULL, '34', '8');

MapPartitions does not execute print

I've a problem that I'm hoping someone can explain it to me.
Let's assume my data looks like this:
('1', ['1', '1', '-1']),
('1', ['1', '2', '-2']),
('1', ['1', '3', '-3']),
('1', ['1', '4', '-4']),
('1', ['1', '5', '-5']),
('1', ['1', '6', '-6']),
('2', ['2', '7', '-7']),
('2', ['2', '8', '-8']),
('2', ['2', '9', '-9'])
and I store it in an RDD with two partitions. One partition contains data for key = '1' and the other contains data for key = '2'. Now, when I run:
def do_something(partition):
print('hello')
for element in partition:
if element[0] != '1':
yield element
my_rdd_new = my_rdd.mapPartitions(do_something)
It doesn't print 'hello' but my_rdd_new contains the right subset of data, i.e.:
('2', ['2', '7', '-7']),
('2', ['2', '8', '-8']),
('2', ['2', '9', '-9'])
Can anyone explain why this is happening?!
If it helps, I'm using spark 2.0.1 and running the code in Jupyter IPython notebook.
Update: It seems Jupyter IPython is the problem. I ran it in the command prompt and it works. Now, the question is: Why does it happen and how it can be fixed?!
Thanks

Remove any spaces between ' ' in cell array Matlab

I have this cell array
aitransp =
Columns 1 through 14
'27' '26' '25' '24' '23' '22' '21' '20' '19' '18' '17' '16' '15' '14'
Columns 15 through 21
'13' '12' '11' ' 9' ' 8' ' 7' ' 1'
As you can see, the last 4 elements have a space between the ' ', such as ' 9'.
Is there any way to remove any spaces occurring between '' in a cell array?
Thanks in advance..
Just use strtrim, you don't have to convert to string
strtrim(aitransp)
You can use regular expressions for greater flexibility:
result = regexprep(aitrasp, '(^\s*)' , ''); %// remove only leading space
result = regexprep(aitrasp, '(^\s*)|(\s*$)' , ''); %// remove leading or trailing space
result = regexprep(aitrasp, '\s' , ''); %// remove any space
for ii = 1:numel(aitransp)
aitransp{ii}(aitransp{ii} == ' ') = '';
end
This should do the trick.

sugarcrm 6.5 set number columns to 3 in one tab/panel, 2 in other tabs

I know how to set the columns in a detailview to 3 columns instead of the default 2 by putting into detailviewdefs.php
(in modules/EvMgr_Pgm/metadata if creating a custom module
or in custom/modules/EvMgr_Pgm/metadata if editing an existing module)
'maxColumns' => '3',
'widths' =>
array (
0 =>
array (
'label' => '8',
'field' => '19',
),
1 =>
array (
'label' => '8',
'field' => '19',
),
2 =>
array (
'label' => '8',
'field' => '19',
),
),
However, that sets the columns for ALL the tabs/panels in a detailview
Is there a way I can have there be 3 columns in one tab/panel and 2 columns (default) in the other tabs/panels?
If you change the widths to exceed 100 it'll recalculate the widths for a panel/table that has 3 or more columns. Try this:
'maxColumns' => '3',
'widths' =>
array (
0 =>
array (
'label' => '10',
'field' => '30',
),
1 =>
array (
'label' => '10',
'field' => '30',
),
2 =>
array (
'label' => '10',
'field' => '30',
),
),
This uses the standard 2 column 10/30 width. When a panel is created with 3 columns it'll recalculate the widths since it is greater than 100. At least as of 6.5.18 it does. Most likely it does for previous versions as well.